bugs fixes

This commit is contained in:
mohammad
2024-10-03 12:46:56 +03:00
parent cc7af3e4e6
commit d9761168e6
11 changed files with 181 additions and 140 deletions

View File

@ -30,14 +30,14 @@ class TwoTouchBloc extends Bloc<TwoTouchEvent, TwoTouchState> {
relay_status_2: status.off, relay_status_2: status.off,
); );
Timer? _timer; Timer? _timer;
bool twoTouchGroup = false; bool twoTouchGroup = false;
List<DeviceModel> devicesList = []; List<DeviceModel> devicesList = [];
List<GroupTwoTouchModel> groupTwoTouchList = []; List<GroupTwoTouchModel> groupTwoTouchList = [];
bool allSwitchesOn = true; bool allSwitchesOn = true;
bool toggleSchedule = true; bool toggleSchedule = true;
List<String> selectedDays = []; List<String> selectedDays = [];
bool createSchedule = false; bool createSchedule = false;
List<ScheduleModel> listSchedule = []; List<ScheduleModel> listSchedule = [];

View File

@ -67,4 +67,7 @@ Map<DeviceType, String> deviceTypeIconMap = {
DeviceType.WH: Assets.waterHeaterIcon, DeviceType.WH: Assets.waterHeaterIcon,
DeviceType.DS: Assets.doorSensorIcon, DeviceType.DS: Assets.doorSensorIcon,
DeviceType.Other: Assets.assetsIconsAC, DeviceType.Other: Assets.assetsIconsAC,
DeviceType.OneTouch: Assets.oneGang,
DeviceType.TowTouch: Assets.twoGang,
DeviceType.ThreeTouch: Assets.assetsIconsGang,
}; };

View File

@ -66,6 +66,12 @@ class DeviceModel {
tempIcon = Assets.waterHeaterIcon; tempIcon = Assets.waterHeaterIcon;
} else if (type == DeviceType.DS) { } else if (type == DeviceType.DS) {
tempIcon = Assets.doorSensorIcon; tempIcon = Assets.doorSensorIcon;
} else if (type == DeviceType.OneTouch) {
tempIcon = Assets.oneGang;
} else if (type == DeviceType.TowTouch) {
tempIcon = Assets.twoGang;
} else if (type == DeviceType.ThreeTouch) {
tempIcon = Assets.assetsIcons3GangSwitch;
} else { } else {
tempIcon = Assets.assetsIconsLogo; tempIcon = Assets.assetsIconsLogo;
} }

View File

@ -19,28 +19,32 @@ class OneGangWizard extends StatelessWidget {
List<GroupOneGangModel> groupOneGangModel = []; List<GroupOneGangModel> groupOneGangModel = [];
return DefaultScaffold( return DefaultScaffold(
title: 'Lights',
child: BlocProvider( child: BlocProvider(
create: (context) => create: (context) =>
OneGangBloc(switchCode: '', oneGangId: device?.uuid ?? '')..add(InitialWizardEvent()), OneGangBloc(switchCode: '', oneGangId: device?.uuid ?? '')
child: BlocBuilder<OneGangBloc, OneGangState>( ..add(InitialWizardEvent()),
builder: (context, state) { child: BlocBuilder<OneGangBloc, OneGangState>(
bool allSwitchesOn = false; builder: (context, state) {
bool allSwitchesOn = false;
if (state is UpdateGroupState) { if (state is UpdateGroupState) {
groupOneGangModel = state.oneGangList; groupOneGangModel = state.oneGangList;
allSwitchesOn = state.allSwitches; allSwitchesOn = state.allSwitches;
} }
return state is LoadingInitialState return state is LoadingInitialState
? const Center( ? const Center(
child: child: DefaultContainer(
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()), width: 50,
) height: 50,
: OneGangList( child: CircularProgressIndicator()),
oneGangList: groupOneGangModel, )
allSwitches: allSwitchesOn, : OneGangList(
); oneGangList: groupOneGangModel,
}, allSwitches: allSwitchesOn,
), );
)); },
),
));
} }
} }

View File

@ -20,31 +20,32 @@ class OneTouchWizard extends StatelessWidget {
List<GroupOneTouchModel> groupOneTouchModel = []; List<GroupOneTouchModel> groupOneTouchModel = [];
return DefaultScaffold( return DefaultScaffold(
title: 'Lights',
child: BlocProvider( child: BlocProvider(
create: (context) => create: (context) =>
OneTouchBloc(switchCode: '', oneTouchId: device?.uuid ?? '') OneTouchBloc(switchCode: '', oneTouchId: device?.uuid ?? '')
..add(InitialWizardEvent()), ..add(InitialWizardEvent()),
child: BlocBuilder<OneTouchBloc, OneTouchState>( child: BlocBuilder<OneTouchBloc, OneTouchState>(
builder: (context, state) { builder: (context, state) {
bool allSwitchesOn = false; bool allSwitchesOn = false;
if (state is UpdateGroupState) { if (state is UpdateGroupState) {
groupOneTouchModel = state.oneTouchList; groupOneTouchModel = state.oneTouchList;
allSwitchesOn = state.allSwitches; allSwitchesOn = state.allSwitches;
} }
return state is LoadingInitialState return state is LoadingInitialState
? const Center( ? const Center(
child: DefaultContainer( child: DefaultContainer(
width: 50, width: 50,
height: 50, height: 50,
child: CircularProgressIndicator()), child: CircularProgressIndicator()),
) )
: OneTouchList( : OneTouchList(
oneTouchList: groupOneTouchModel, oneTouchList: groupOneTouchModel,
allSwitches: allSwitchesOn, allSwitches: allSwitchesOn,
); );
}, },
), ),
)); ));
} }
} }

View File

@ -17,29 +17,33 @@ class ThreeGangWizard extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return DefaultScaffold( return DefaultScaffold(
title: 'Lights',
child: BlocProvider( child: BlocProvider(
create: (context) => ThreeGangBloc(switchCode: '', threeGangId: device?.uuid ?? '') create: (context) =>
..add(InitialEvent(groupScreen: device != null ? false : true)), ThreeGangBloc(switchCode: '', threeGangId: device?.uuid ?? '')
child: BlocBuilder<ThreeGangBloc, ThreeGangState>( ..add(InitialEvent(groupScreen: device != null ? false : true)),
builder: (context, state) { child: BlocBuilder<ThreeGangBloc, ThreeGangState>(
List<GroupThreeGangModel> groupThreeGangModel = []; builder: (context, state) {
bool allSwitchesOn = false; List<GroupThreeGangModel> groupThreeGangModel = [];
bool allSwitchesOn = false;
if (state is UpdateGroupState) { if (state is UpdateGroupState) {
groupThreeGangModel = state.threeGangList; groupThreeGangModel = state.threeGangList;
allSwitchesOn = state.allSwitches; allSwitchesOn = state.allSwitches;
} }
return state is LoadingInitialState return state is LoadingInitialState
? const Center( ? const Center(
child: child: DefaultContainer(
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()), width: 50,
) height: 50,
: ThreeGangList( child: CircularProgressIndicator()),
threeGangList: groupThreeGangModel, )
allSwitches: allSwitchesOn, : ThreeGangList(
); threeGangList: groupThreeGangModel,
}, allSwitches: allSwitchesOn,
), );
)); },
),
));
} }
} }

View File

@ -17,29 +17,34 @@ class ThreeTouchWizard extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return DefaultScaffold( return DefaultScaffold(
title: 'Lights',
child: BlocProvider( child: BlocProvider(
create: (context) => ThreeTouchBloc(switchCode: '', threeTouchId: device?.uuid ?? '') create: (context) =>
..add(InitialEvent(groupScreen: device != null ? false : true)), ThreeTouchBloc(switchCode: '', threeTouchId: device?.uuid ?? '')
child: BlocBuilder<ThreeTouchBloc, ThreeTouchState>( ..add(InitialEvent(groupScreen: device != null ? false : true)),
builder: (context, state) { child: BlocBuilder<ThreeTouchBloc, ThreeTouchState>(
List<GroupThreeTouchModel> groupThreeTouchModel = []; builder: (context, state) {
bool allSwitchesOn = false; List<GroupThreeTouchModel> groupThreeTouchModel = [];
bool allSwitchesOn = false;
if (state is UpdateGroupState) { if (state is UpdateGroupState) {
groupThreeTouchModel = state.threeTouchList; groupThreeTouchModel = state.threeTouchList;
allSwitchesOn = state.allSwitches; allSwitchesOn = state.allSwitches;
} }
return state is LoadingInitialState return state is LoadingInitialState
? const Center( ? const Center(
child: child: DefaultContainer(
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()), width: 50,
) height: 50,
: ThreeTouchList( child: CircularProgressIndicator()),
threeTouchList: groupThreeTouchModel, )
allSwitches: allSwitchesOn, :
); ThreeTouchList(
}, threeTouchList: groupThreeTouchModel,
), allSwitches: allSwitchesOn,
)); );
},
),
));
} }
} }

View File

@ -19,28 +19,32 @@ class TwoGangWizard extends StatelessWidget {
List<GroupTwoGangModel> groupTwoGangModel = []; List<GroupTwoGangModel> groupTwoGangModel = [];
return DefaultScaffold( return DefaultScaffold(
title: 'Lights',
child: BlocProvider( child: BlocProvider(
create: (context) => create: (context) =>
TwoGangBloc(switchCode: '', twoGangId: device?.uuid ?? '')..add(InitialWizardEvent()), TwoGangBloc(switchCode: '', twoGangId: device?.uuid ?? '')
child: BlocBuilder<TwoGangBloc, TwoGangState>( ..add(InitialWizardEvent()),
builder: (context, state) { child: BlocBuilder<TwoGangBloc, TwoGangState>(
bool allSwitchesOn = false; builder: (context, state) {
bool allSwitchesOn = false;
if (state is UpdateGroupState) { if (state is UpdateGroupState) {
groupTwoGangModel = state.twoGangList; groupTwoGangModel = state.twoGangList;
allSwitchesOn = state.allSwitches; allSwitchesOn = state.allSwitches;
} }
return state is LoadingInitialState return state is LoadingInitialState
? const Center( ? const Center(
child: child: DefaultContainer(
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()), width: 50,
) height: 50,
: TwoGangList( child: CircularProgressIndicator()),
twoGangList: groupTwoGangModel, )
allSwitches: allSwitchesOn, : TwoGangList(
); twoGangList: groupTwoGangModel,
}, allSwitches: allSwitchesOn,
), );
)); },
),
));
} }
} }

View File

@ -20,28 +20,32 @@ class TwoTouchWizard extends StatelessWidget {
List<GroupTwoTouchModel> groupTwoTouchModel = []; List<GroupTwoTouchModel> groupTwoTouchModel = [];
return DefaultScaffold( return DefaultScaffold(
title: 'Lights',
child: BlocProvider( child: BlocProvider(
create: (context) => create: (context) =>
TwoTouchBloc(switchCode: '', twoTouchId: device?.uuid ?? '')..add(InitialWizardEvent()), TwoTouchBloc(switchCode: '', twoTouchId: device?.uuid ?? '')
child: BlocBuilder<TwoTouchBloc, TwoTouchState>( ..add(InitialWizardEvent()),
builder: (context, state) { child: BlocBuilder<TwoTouchBloc, TwoTouchState>(
bool allSwitchesOn = false; builder: (context, state) {
bool allSwitchesOn = false;
if (state is UpdateGroupState) { if (state is UpdateGroupState) {
groupTwoTouchModel = state.twoTouchList; groupTwoTouchModel = state.twoTouchList;
allSwitchesOn = state.allSwitches; allSwitchesOn = state.allSwitches;
} }
return state is LoadingInitialState return state is LoadingInitialState
? const Center( ? const Center(
child: child: DefaultContainer(
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()), width: 50,
) height: 50,
: TwoTouchList( child: CircularProgressIndicator()),
twoTouchList: groupTwoTouchModel, )
allSwitches: allSwitchesOn, : TwoTouchList(
); twoTouchList: groupTwoTouchModel,
}, allSwitches: allSwitchesOn,
), );
)); },
),
));
} }
} }

View File

@ -4,7 +4,10 @@ import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class DevicesDefaultSwitch extends StatelessWidget { class DevicesDefaultSwitch extends StatelessWidget {
const DevicesDefaultSwitch( const DevicesDefaultSwitch(
{super.key, required this.switchValue, required this.action, this.secondAction}); {super.key,
required this.switchValue,
required this.action,
this.secondAction});
final bool switchValue; final bool switchValue;
final Function action; final Function action;
@ -22,7 +25,9 @@ class DevicesDefaultSwitch extends StatelessWidget {
child: Container( child: Container(
height: 60, height: 60,
decoration: BoxDecoration( decoration: BoxDecoration(
color: switchValue ? ColorsManager.primaryColor : Colors.white, color: switchValue
? ColorsManager.switchButton.withOpacity(0.6)
: Colors.white,
borderRadius: const BorderRadius.only( borderRadius: const BorderRadius.only(
topLeft: Radius.circular(15), topLeft: Radius.circular(15),
bottomLeft: Radius.circular(15), bottomLeft: Radius.circular(15),
@ -30,9 +35,10 @@ class DevicesDefaultSwitch extends StatelessWidget {
), ),
child: Center( child: Center(
child: BodyMedium( child: BodyMedium(
fontSize: 14,
text: "ON", text: "ON",
fontColor: switchValue ? Colors.white : null, fontColor: switchValue ? Colors.white : null,
fontWeight: FontWeight.bold, fontWeight: FontWeight.w700,
), ),
), ),
), ),
@ -50,7 +56,9 @@ class DevicesDefaultSwitch extends StatelessWidget {
child: Container( child: Container(
height: 60, height: 60,
decoration: BoxDecoration( decoration: BoxDecoration(
color: switchValue ? Colors.white : ColorsManager.primaryColor, color: switchValue
? Colors.white
: ColorsManager.switchButton.withOpacity(0.6),
borderRadius: const BorderRadius.only( borderRadius: const BorderRadius.only(
topRight: Radius.circular(15), topRight: Radius.circular(15),
bottomRight: Radius.circular(15), bottomRight: Radius.circular(15),
@ -58,9 +66,10 @@ class DevicesDefaultSwitch extends StatelessWidget {
), ),
child: Center( child: Center(
child: BodyMedium( child: BodyMedium(
fontSize: 14,
text: "OFF", text: "OFF",
fontColor: switchValue ? null : Colors.white, fontColor: switchValue ? null : Colors.white,
fontWeight: FontWeight.bold, fontWeight: FontWeight.w700,
), ),
), ),
), ),

View File

@ -5,7 +5,8 @@ abstract class ColorsManager {
static const Color switchOffColor = Color(0x7F8D99AE); static const Color switchOffColor = Color(0x7F8D99AE);
static const Color primaryColor = Color(0xFF0030CB); static const Color primaryColor = Color(0xFF0030CB);
static const Color secondaryTextColor = Color(0xFF848484); static const Color secondaryTextColor = Color(0xFF848484);
static Color primaryColorWithOpacity = const Color(0xFF023DFE).withOpacity(0.6); static Color primaryColorWithOpacity =
const Color(0xFF023DFE).withOpacity(0.6);
static const Color onPrimaryColor = Colors.white; static const Color onPrimaryColor = Colors.white;
static const Color secondaryColor = Color(0xFF023DFE); static const Color secondaryColor = Color(0xFF023DFE);
static const Color onSecondaryColor = Color(0xFF023DFE); static const Color onSecondaryColor = Color(0xFF023DFE);
@ -27,5 +28,5 @@ abstract class ColorsManager {
static const Color red = Colors.red; static const Color red = Colors.red;
static const Color graysColor = Color(0xffEBEBEB); static const Color graysColor = Color(0xffEBEBEB);
static const Color textGray = Color(0xffD5D5D5); static const Color textGray = Color(0xffD5D5D5);
static const Color switchButton = Color(0xff023DFE);
} }