mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-27 18:04:55 +00:00
Refactor device-related views to improve code structure and readability. Add error handling for authentication token in the splash view. Remove unnecessary NavCubit from the app initialization.
73 lines
2.8 KiB
Dart
73 lines
2.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:syncrow_app/features/devices/bloc/devices_cubit.dart';
|
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
|
import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface.dart';
|
|
import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_list.dart';
|
|
import 'package:syncrow_app/features/devices/view/widgets/ACs/category_view_app_bar.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
|
|
|
import '../../../../../generated/assets.dart';
|
|
import '../../../../../utils/resource_manager/color_manager.dart';
|
|
|
|
class ACsView extends StatelessWidget {
|
|
const ACsView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocBuilder<DevicesCubit, DevicesState>(
|
|
builder: (context, state) {
|
|
return BlocBuilder<DevicesCubit, DevicesState>(
|
|
builder: (context, state) {
|
|
DeviceModel? selectedAC;
|
|
if (DevicesCubit.get(context).getSelectedDevice() is DeviceModel) {
|
|
selectedAC =
|
|
DevicesCubit.get(context).getSelectedDevice() as DeviceModel;
|
|
}
|
|
return AnnotatedRegion(
|
|
value: SystemUiOverlayStyle(
|
|
statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
|
|
statusBarIconBrightness: Brightness.light,
|
|
),
|
|
child: SafeArea(
|
|
child: Scaffold(
|
|
backgroundColor: ColorsManager.backgroundColor,
|
|
extendBodyBehindAppBar: true,
|
|
extendBody: true,
|
|
appBar: const CategoryViewAppBar(),
|
|
body: Container(
|
|
width: MediaQuery.sizeOf(context).width,
|
|
height: MediaQuery.sizeOf(context).height,
|
|
decoration: const BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage(
|
|
Assets.imagesBackground,
|
|
),
|
|
fit: BoxFit.cover,
|
|
opacity: 0.4,
|
|
),
|
|
),
|
|
child: Padding(
|
|
padding: EdgeInsets.only(
|
|
top: Constants.appBarHeight,
|
|
left: Constants.defaultPadding,
|
|
right: Constants.defaultPadding,
|
|
),
|
|
child: SizedBox.expand(
|
|
child: selectedAC != null
|
|
? AcInterface(deviceModel: selectedAC)
|
|
: const ACsList(),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|