fixed padding bug

fixed AC interface routing issue
This commit is contained in:
Mohammad Salameh
2024-03-04 17:10:34 +03:00
parent 282739acf7
commit 33b7149dde
5 changed files with 119 additions and 106 deletions
@@ -289,6 +289,7 @@ class DevicesCubit extends Cubit<DevicesState> {
device.status = true;
}
}
updateDevicesStatus(category);
emit(CategorySwitchChanged());
}
@@ -319,6 +320,7 @@ class DevicesCubit extends Cubit<DevicesState> {
for (var device in category.devices) {
device.status = false;
}
changeCategorySwitchValue(category);
updateDevicesStatus(category);
emit(CategorySwitchChanged());
}
@@ -327,6 +329,7 @@ class DevicesCubit extends Cubit<DevicesState> {
for (var device in category.devices) {
device.status = true;
}
changeCategorySwitchValue(category);
updateDevicesStatus(category);
emit(CategorySwitchChanged());
}
+5 -1
View File
@@ -11,7 +11,11 @@ class CategoriesView extends StatelessWidget {
return BlocProvider(
create: (context) => DevicesCubit(),
child: BlocBuilder<DevicesCubit, DevicesState>(
builder: (context, state) => const DevicesViewBody(),
builder: (context, state) => Container(
padding: const EdgeInsets.all(8),
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height,
child: const DevicesViewBody()),
),
);
}
@@ -1,4 +1,5 @@
import 'package:flutter/material.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_category_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_mode_control_unit.dart';
@@ -18,75 +19,79 @@ class ACsList extends StatelessWidget {
@override
Widget build(BuildContext context) {
DevicesCategoryModel category = DevicesCubit.categories[0];
return SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// universal AC controller
const SizedBox(height: 10),
const BodySmall(text: "All ACs"),
const SizedBox(height: 5),
UniversalSwitch(
category: category,
),
const SizedBox(height: 10),
const UniversalACTemp(),
const SizedBox(height: 10),
return BlocBuilder<DevicesCubit, DevicesState>(
builder: (context, state) {
return SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// universal AC controller
const SizedBox(height: 10),
const BodySmall(text: "All ACs"),
const SizedBox(height: 5),
UniversalSwitch(
category: category,
),
const SizedBox(height: 10),
const UniversalACTemp(),
const SizedBox(height: 10),
// other ACs controls
ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.all(0),
itemCount: category.devices.length,
itemBuilder: (context, index) {
ACModel ac = category.devices[index] as ACModel;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
// other ACs controls
ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.all(0),
itemCount: category.devices.length,
itemBuilder: (context, index) {
ACModel ac = category.devices[index] as ACModel;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
BodySmall(text: category.devices[index].name ?? ""),
IconButton(
onPressed: () {
DevicesCubit.get(context).selectDevice(ac);
},
icon: const Icon(
Icons.arrow_forward_ios,
),
style: ButtonStyle(
padding: MaterialStateProperty.all(
const EdgeInsets.all(0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
BodySmall(text: category.devices[index].name ?? ""),
IconButton(
onPressed: () {
DevicesCubit.get(context).selectDevice(ac);
},
icon: const Icon(
Icons.arrow_forward_ios,
),
style: ButtonStyle(
padding: MaterialStateProperty.all(
const EdgeInsets.all(0),
),
iconSize: MaterialStateProperty.all(15),
alignment: Alignment.bottomRight,
),
),
iconSize: MaterialStateProperty.all(15),
alignment: Alignment.bottomRight,
),
],
),
const SizedBox(height: 5),
if (category.devices[index] is ACModel)
DevicesDefaultSwitch(
model: ac,
),
const SizedBox(height: 10),
ACTempWidget(
ac,
),
const SizedBox(height: 10),
if (category.devices[index] is ACModel)
ACModeControlUnit(
model: ac,
),
const SizedBox(height: 10),
],
),
const SizedBox(height: 5),
if (category.devices[index] is ACModel)
DevicesDefaultSwitch(
model: ac,
),
const SizedBox(height: 10),
ACTempWidget(
ac,
),
const SizedBox(height: 10),
if (category.devices[index] is ACModel)
ACModeControlUnit(
model: ac,
),
const SizedBox(height: 10),
],
);
},
);
},
),
],
),
],
),
);
},
);
}
}
@@ -19,49 +19,53 @@ class ACsView extends StatelessWidget {
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => AcCubit(),
child: BlocBuilder<AcCubit, AcState>(
child: BlocBuilder<DevicesCubit, DevicesState>(
builder: (context, state) {
ACModel? selectedAC;
if (DevicesCubit.get(context).getSelectedDevice() is ACModel) {
selectedAC =
DevicesCubit.get(context).getSelectedDevice() as ACModel;
}
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 DefaultAppBar(),
body: Container(
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
Assets.imagesBackground,
return BlocBuilder<AcCubit, AcState>(
builder: (context, state) {
ACModel? selectedAC;
if (DevicesCubit.get(context).getSelectedDevice() is ACModel) {
selectedAC =
DevicesCubit.get(context).getSelectedDevice() as ACModel;
}
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 DefaultAppBar(),
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: const EdgeInsets.only(
top: 60, right: 15, left: 15, bottom: 80),
child: SizedBox.expand(
child: selectedAC != null
? AcInterface(acModel: selectedAC)
: const ACsList(),
),
),
fit: BoxFit.cover,
opacity: 0.4,
),
),
child: Padding(
padding: const EdgeInsets.only(
top: 60, right: 15, left: 15, bottom: 80),
child: SizedBox.expand(
child: selectedAC != null
? AcInterface(acModel: selectedAC)
: const ACsList(),
),
bottomNavigationBar: const DefaultNavBar(),
),
),
bottomNavigationBar: const DefaultNavBar(),
),
),
);
},
);
},
),
@@ -26,10 +26,7 @@ class DevicesViewBody extends StatelessWidget {
: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height -
MediaQuery.sizeOf(context).height * .3,
Expanded(
child: PageView(
controller: pageController,
children: const [