one gang wizard &two Gang wizard & wh wizard

This commit is contained in:
mohammad
2024-09-26 16:26:39 +03:00
parent 8508995108
commit 4e345db842
21 changed files with 1210 additions and 170 deletions

View File

@ -51,13 +51,7 @@ class ThreeGangScreen extends StatelessWidget {
? const Center(
child:
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
)
: device == null
? ThreeGangList(
threeGangList: groupThreeGangModel,
allSwitches: allSwitchesOn,
)
: RefreshIndicator(
) : RefreshIndicator(
onRefresh: () async {
BlocProvider.of<ThreeGangBloc>(context)
.add(InitialEvent(groupScreen: device != null ? false : true));

View File

@ -0,0 +1,61 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/three_gang_bloc/three_gang_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/three_gang_bloc/three_gang_event.dart';
import 'package:syncrow_app/features/devices/bloc/three_gang_bloc/three_gang_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/model/group_three_gang_model.dart';
import 'package:syncrow_app/features/devices/model/three_gang_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_list.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
class ThreeGangWizard extends StatelessWidget {
const ThreeGangWizard({super.key, this.device});
final DeviceModel? device;
@override
Widget build(BuildContext context) {
return DefaultScaffold(
child: BlocProvider(
create: (context) =>
ThreeGangBloc(switchCode: '', threeGangId: device?.uuid ?? '')
..add(InitialEvent(groupScreen: device != null ? false : true)),
child: BlocBuilder<ThreeGangBloc, ThreeGangState>(
builder: (context, state) {
ThreeGangModel threeGangModel = ThreeGangModel(
firstSwitch: false,
secondSwitch: false,
thirdSwitch: false,
firstCountDown: 0,
secondCountDown: 0,
thirdCountDown: 0);
List<GroupThreeGangModel> groupThreeGangModel = [];
bool allSwitchesOn = false;
if (state is LoadingNewSate) {
threeGangModel = state.threeGangModel;
} else if (state is UpdateState) {
threeGangModel = state.threeGangModel;
} else if (state is UpdateGroupState) {
groupThreeGangModel = state.threeGangList;
allSwitchesOn = state.allSwitches;
}
return state is LoadingInitialState
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator()),
)
: ThreeGangList(
threeGangList: groupThreeGangModel,
allSwitches: allSwitchesOn,
);
},
),
));
}
}