schedule for one gang and two gang and three gange

This commit is contained in:
mohammad
2024-09-18 13:00:46 +03:00
parent 42b5ff105f
commit d9cd24e7f0
2 changed files with 0 additions and 406 deletions

View File

@ -18,175 +18,6 @@ import 'package:syncrow_app/utils/context_extension.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
// class OneGangTimerScreen extends StatelessWidget {
// final DeviceModel? device;
// final String? deviceCode;
// const OneGangTimerScreen({super.key,this.device,this.deviceCode});
//
// @override
// Widget build(BuildContext context) {
// return AnnotatedRegion(
// value: SystemUiOverlayStyle(
// statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
// statusBarIconBrightness: Brightness.light,
// ),
// child: Scaffold(
// backgroundColor: ColorsManager.backgroundColor,
// extendBodyBehindAppBar: true,
// extendBody: true,
// appBar: AppBar(
// backgroundColor: Colors.transparent,
// centerTitle: true,
// title: const BodyLarge(
// text: 'Schedule',
// fontColor: ColorsManager.primaryColor,
// fontWeight: FontsManager.bold,
// ),
// ),
// body: SafeArea(
// child: BlocProvider(
// create: (context) => OneGangBloc(
// switchCode: 'switch_1',
// oneGangId: device!.uuid ?? '')..
// ..add(GetCounterEvent(deviceCode: deviceCode!)),
// child: BlocBuilder<OneGangBloc, OneGangState>(
// builder: (context, state) {
// Duration duration = Duration.zero;
// int countNum = 0;
// int tabNum = 0;
// if (state is UpdateTimerState) {
// countNum = state.seconds;
// } else if (state is TimerRunInProgress) {
// countNum = state.remainingTime;
// } else if (state is TimerRunComplete) {
// countNum = 0;
// } else if (state is LoadingNewSate) {
// countNum = 0;
// }
//
// if (state is ChangeSlidingSegmentState) {
// tabNum = state.value;
// }
// return PopScope(
// canPop: false,
// onPopInvoked: (didPop) {
// if (!didPop) {
// BlocProvider.of<OneGangBloc>(context).add(OnClose());
// Navigator.pop(context);
// }
// },
// child: Container(
// width: MediaQuery.sizeOf(context).width,
// height: MediaQuery.sizeOf(context).height,
// padding: const EdgeInsets.all(24),
// decoration: const BoxDecoration(
// image: DecorationImage(
// image: AssetImage(
// Assets.assetsImagesBackground,
// ),
// fit: BoxFit.cover,
// opacity: 0.4,
// ),
// ),
// child: state is LoadingInitialState || state is LoadingNewSate
// ? const Center(
// child: DefaultContainer(
// width: 50, height: 50, child: CircularProgressIndicator()),
// )
// : Column(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Container(
// width: MediaQuery.sizeOf(context).width,
// decoration: const ShapeDecoration(
// color: ColorsManager.slidingBlueColor,
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.all(Radius.circular(20)),
// ),
// ),
// child: CupertinoSlidingSegmentedControl<int>(
// thumbColor: ColorsManager.slidingBlueColor,
// onValueChanged: (value) {
// BlocProvider.of<OneGangBloc>(context)
// .add(ChangeSlidingSegment(value: value ?? 0));
// },
// groupValue:
// state is ChangeSlidingSegmentState ? state.value : 0,
// backgroundColor: Colors.white,
// children: <int, Widget>{
// 0: Container(
// padding: const EdgeInsets.symmetric(vertical: 10),
// child: BodySmall(
// text: 'Countdown',
// style: context.bodySmall.copyWith(
// color: ColorsManager.blackColor,
// fontSize: 12,
// fontWeight: FontWeight.w400,
// ),
// ),
// ),
// 1: Container(
// padding: const EdgeInsets.symmetric(vertical: 10),
// child: Text(
// 'Schedule',
// style: context.bodySmall.copyWith(
// color: ColorsManager.blackColor,
// fontSize: 12,
// fontWeight: FontWeight.w400,
// ),
// ),
// ),
// },
// ),
// ),
// if (tabNum == 0)
// countNum > 0
// ? BodyLarge(
// text: _formatDuration(countNum),
// fontColor: ColorsManager.slidingBlueColor,
// fontSize: 40,
// )
// : CupertinoTimerPicker(
// mode: CupertinoTimerPickerMode.hm,
// onTimerDurationChanged: (Duration newDuration) {
// duration = newDuration;
// },
// ),
// if (tabNum == 0)
// GestureDetector(
// onTap: () {
// if (state is LoadingNewSate) {
// return;
// }
// if (countNum > 0) {
// BlocProvider.of<OneGangBloc>(context).add(
// SetCounterValue(
// deviceCode: deviceCode!,
// duration: Duration.zero));
// } else if (duration != Duration.zero) {
// BlocProvider.of<OneGangBloc>(context).add(
// SetCounterValue(
// deviceCode: deviceCode!, duration: duration));
// }
// },
// child: SvgPicture.asset(
// countNum > 0 ? Assets.pauseIcon : Assets.playIcon))
// ],
// )));
// },
// ),
// ),
// ),
// ),
// );
// }
// String _formatDuration(int seconds) {
// final hours = (seconds ~/ 3600).toString().padLeft(2, '0');
// final minutes = ((seconds % 3600) ~/ 60).toString().padLeft(2, '0');
// final secs = (seconds % 60).toString().padLeft(2, '0');
// return '$hours:$minutes:$secs';
// }
// }
class TimerScheduleScreen extends StatelessWidget {

View File

@ -18,243 +18,6 @@ import 'package:syncrow_app/utils/context_extension.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
// class TimerScreen extends StatelessWidget {
// final DeviceModel device;
// final String deviceCode;
// final String switchCode;
// const TimerScreen(
// {required this.device,
// required this.deviceCode,
// required this.switchCode,
// super.key});
//
// @override
// Widget build(BuildContext context) {
// return AnnotatedRegion(
// value: SystemUiOverlayStyle(
// statusBarColor: ColorsManager.primaryColor.withOpacity(0.5),
// statusBarIconBrightness: Brightness.light,
// ),
// child:
//
// BlocProvider(
// create: (context) => ThreeGangBloc(
// switchCode: switchCode, threeGangId: device.uuid ?? '')..add(GetScheduleEvent())
// ..add(GetCounterEvent(deviceCode: deviceCode)),
// child: BlocBuilder<ThreeGangBloc, ThreeGangState>(
// builder: (context, state) {
// final threeGangBloc = BlocProvider.of<ThreeGangBloc>(context);
//
// Duration duration = Duration.zero;
// int countNum = 0;
// int tabNum = 0;
// if (state is UpdateTimerState) {
// countNum = state.seconds;
// } else if (state is TimerRunInProgress) {
// countNum = state.remainingTime;
// } else if (state is TimerRunComplete) {
// countNum = 0;
// } else if (state is LoadingNewSate) {
// countNum = 0;
// }
//
// if (state is ChangeSlidingSegmentState) {
// tabNum = state.value;
// }
// return Scaffold(
// backgroundColor: ColorsManager.backgroundColor,
// extendBodyBehindAppBar: true,
// extendBody: true,
// appBar: AppBar(
// backgroundColor: Colors.transparent,
// centerTitle: true,
// title: const BodyLarge(
// text: 'Schedule',
// fontColor: ColorsManager.primaryColor,
// fontWeight: FontsManager.bold,
// ),
// actions: [
// if (tabNum == 1)
// threeGangBloc.createSchedule == true
// ? TextButton(onPressed: () {
// threeGangBloc.add(ThreeGangSave() );
// }, child: const Text('Save'))
// : IconButton(
// onPressed: () {
// threeGangBloc.toggleCreateSchedule();
// },
// icon: const Icon(Icons.add),
// ),
// ],
// ),
// body: SafeArea(
// child:PopScope(
// canPop: false,
// onPopInvoked: (didPop) {
// if (!didPop) {
// BlocProvider.of<ThreeGangBloc>(context).add(OnClose());
// Navigator.pop(context);
// }
// },
// child: Container(
// width: MediaQuery.sizeOf(context).width,
// padding: const EdgeInsets.all(24),
// decoration: const BoxDecoration(
// image: DecorationImage(
// image: AssetImage(
// Assets.assetsImagesBackground,
// ),
// fit: BoxFit.cover,
// opacity: 0.4,
// ),
// ),
// child: state is LoadingInitialState ||
// state is LoadingNewSate
// ? const Center(
// child: DefaultContainer(
// width: 50,
// height: 50,
// child: CircularProgressIndicator()),
// )
// : Column(
// children: [
// Container(
// width: MediaQuery.sizeOf(context).width,
// decoration: const ShapeDecoration(
// color: ColorsManager.slidingBlueColor,
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.all(
// Radius.circular(20)),
// ),
// ),
// child:
// CupertinoSlidingSegmentedControl<int>(
// thumbColor:
// ColorsManager.slidingBlueColor,
// onValueChanged: (value) {
// BlocProvider.of<ThreeGangBloc>(context)
// .add(ChangeSlidingSegment(
// value: value ?? 0));
// },
// groupValue:
// state is ChangeSlidingSegmentState
// ? state.value
// : 0,
// backgroundColor: Colors.white,
// children: <int, Widget>{
// 0: Container(
// padding: const EdgeInsets.symmetric(
// vertical: 10),
// child: BodySmall(
// text: 'Countdown',
// style: context.bodySmall.copyWith(
// color: ColorsManager.blackColor,
// fontSize: 12,
// fontWeight: FontWeight.w400,
// ),
// ),
// ),
// 1: Container(
// padding: const EdgeInsets.symmetric(
// vertical: 10),
// child: Text(
// 'Schedule',
// style: context.bodySmall.copyWith(
// color: ColorsManager.blackColor,
// fontSize: 12,
// fontWeight: FontWeight.w400,
// ),
// ),
// ),
// },
// ),
// ),
// if (tabNum == 0)
// countNum > 0
// ? BodyLarge(
// text: _formatDuration(countNum),
// fontColor:
// ColorsManager.slidingBlueColor,
// fontSize: 40,
// )
// : CupertinoTimerPicker(
// mode: CupertinoTimerPickerMode.hm,
// onTimerDurationChanged:
// (Duration newDuration) {
// duration = newDuration;
// },
// ),
// if (tabNum == 0)
// GestureDetector(
// onTap: () {
// if (state is LoadingNewSate) {
// return;
// }
// if (countNum > 0) {
// BlocProvider.of<ThreeGangBloc>(
// context)
// .add(SetCounterValue(
// deviceCode: deviceCode,
// duration: Duration.zero));
// } else if (duration !=
// Duration.zero) {
// BlocProvider.of<ThreeGangBloc>(
// context)
// .add(SetCounterValue(
// deviceCode: deviceCode,
// duration: duration));
// }
// },
// child: SvgPicture.asset(countNum > 0
// ? Assets.pauseIcon
// : Assets.playIcon)),
// if (tabNum == 1)
// SizedBox(
// child: threeGangBloc.createSchedule == true
// ? CreateSchedule(
// onToggleChanged: (bool isOn) {
// threeGangBloc.toggleSchedule = isOn;
// },
// onDateTimeChanged: (DateTime dateTime) {
// threeGangBloc.selectedTime = dateTime;
// },
// days: threeGangBloc.days,
// selectDays: (List<String>selectedDays) {
// threeGangBloc.selectedDays = selectedDays;
// },
// ) : SizedBox(
// height: MediaQuery.of(context).size.height/1.9,
// child: ScheduleListView(
// listSchedule: threeGangBloc.listSchedule, // Pass the schedule list here
// onDismissed: (scheduleId) {
// threeGangBloc.listSchedule.removeWhere((schedule) => schedule.scheduleId == scheduleId);
// threeGangBloc.add(DeleteScheduleEvent(id: scheduleId));
// },
// onToggleSchedule: (scheduleId, isEnabled) {
// threeGangBloc.add(ToggleScheduleEvent(
// id: scheduleId,
// toggle: isEnabled,
// ));
// },
// ),
// ))
// ],
// )))
// ),
// );
// },
// ),
// ),
// );
// }
//
// String _formatDuration(int seconds) {
// final hours = (seconds ~/ 3600).toString().padLeft(2, '0');
// final minutes = ((seconds % 3600) ~/ 60).toString().padLeft(2, '0');
// final secs = (seconds % 60).toString().padLeft(2, '0');
// return '$hours:$minutes:$secs';
// }
// }
class TimerScheduleScreen extends StatelessWidget {