mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 09:45:22 +00:00
schedule for one gang and two gang and three gange
This commit is contained in:
@ -23,7 +23,7 @@ class CreateSchedule extends StatefulWidget {
|
||||
|
||||
class _CreateScheduleState extends State<CreateSchedule> {
|
||||
List<String> selectedDays = []; // List of selected days
|
||||
bool isOn = false; // Boolean state for the ON/OFF toggle
|
||||
bool isOn = true; // Boolean state for the ON/OFF toggle
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -114,19 +114,18 @@ class _CreateScheduleState extends State<CreateSchedule> {
|
||||
children: [
|
||||
Text(
|
||||
isOn ? 'ON' : 'OFF', // Change text based on state
|
||||
style: TextStyle(
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: isOn ? Colors.green : Colors.red, // Change color based on state
|
||||
),
|
||||
),
|
||||
CircleAvatar(
|
||||
backgroundColor: isOn
|
||||
? ColorsManager.secondaryColor.withOpacity(0.6)
|
||||
: Colors.red.withOpacity(0.6), // Change background color based on state
|
||||
child: Icon(
|
||||
child: const Icon(
|
||||
Icons.power_settings_new,
|
||||
color: isOn ? Colors.green : Colors.red, // Change icon color
|
||||
color: ColorsManager.onPrimaryColor, // Change icon color
|
||||
),
|
||||
),
|
||||
],
|
||||
|
@ -9,43 +9,43 @@ class EmptySchedule extends StatelessWidget {
|
||||
const EmptySchedule({super.key});
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
children: [
|
||||
Center(
|
||||
child: SvgPicture.asset(
|
||||
height: 100,
|
||||
width: 100,
|
||||
Assets.emptySchedule),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Center(
|
||||
child: Text(
|
||||
'Please add',
|
||||
style: context.displaySmall
|
||||
.copyWith(
|
||||
color: const Color(
|
||||
0XFFD5D5D5),
|
||||
return SizedBox(
|
||||
height: 180,
|
||||
width: 180,
|
||||
child: Center(child: Column(
|
||||
children: [
|
||||
Center(
|
||||
child: SvgPicture.asset(
|
||||
height: 100,
|
||||
width: 100,
|
||||
Assets.emptySchedule),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Center(
|
||||
child: Text(
|
||||
'Please add',
|
||||
style: context.displaySmall
|
||||
.copyWith(
|
||||
color: const Color(
|
||||
0XFFD5D5D5),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Text(
|
||||
'a new schedule',
|
||||
style: context.displaySmall
|
||||
.copyWith(
|
||||
color: const Color(
|
||||
0XFFD5D5D5),
|
||||
Center(
|
||||
child: Text(
|
||||
'a new schedule',
|
||||
style: context.displaySmall
|
||||
.copyWith(
|
||||
color: const Color(
|
||||
0XFFD5D5D5),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),);
|
||||
],
|
||||
),
|
||||
],
|
||||
),),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
120
lib/features/shared_widgets/schedule_list.dart
Normal file
120
lib/features/shared_widgets/schedule_list.dart
Normal file
@ -0,0 +1,120 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_app/features/devices/model/schedule_model.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'empty_schedule.dart'; // for SVG icons
|
||||
|
||||
|
||||
class ScheduleListView extends StatelessWidget {
|
||||
final List<ScheduleModel> listSchedule;
|
||||
final Function(String) onDismissed;
|
||||
final Function(String, bool) onToggleSchedule;
|
||||
const ScheduleListView({
|
||||
Key? key,
|
||||
required this.listSchedule,
|
||||
required this.onDismissed,
|
||||
required this.onToggleSchedule,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: listSchedule.isNotEmpty
|
||||
? SizedBox(
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: listSchedule.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Dismissible(
|
||||
key: Key(listSchedule[index].scheduleId),
|
||||
background: Container(
|
||||
padding: const EdgeInsets.only(right: 10),
|
||||
alignment: AlignmentDirectional.centerEnd,
|
||||
decoration: const ShapeDecoration(
|
||||
color: Color(0xFFFF0000),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10, right: 10),
|
||||
child: SvgPicture.asset(
|
||||
Assets.assetsDeleteIcon,
|
||||
width: 20,
|
||||
height: 22,
|
||||
),
|
||||
),
|
||||
),
|
||||
direction: DismissDirection.endToStart,
|
||||
onDismissed: (direction) {
|
||||
|
||||
onDismissed(listSchedule[index].scheduleId);
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Schedule removed')),
|
||||
);
|
||||
},
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
|
||||
},
|
||||
child: DefaultContainer(
|
||||
padding: const EdgeInsets.all(20),
|
||||
height: MediaQuery.of(context).size.height / 6.4,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
BodyLarge(
|
||||
text: listSchedule[index].time,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontColor: Colors.black,
|
||||
fontSize: 22,
|
||||
),
|
||||
Text(listSchedule[index].days.join(' ')),
|
||||
Text('Function ${listSchedule[index].enable ? "ON" : "OFF"}'),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: const BodyMedium(
|
||||
text: '',
|
||||
fontWeight: FontWeight.normal,
|
||||
),
|
||||
trailing: Transform.scale(
|
||||
scale: .8,
|
||||
child: CupertinoSwitch(
|
||||
value: listSchedule[index].enable,
|
||||
onChanged: (value) {
|
||||
onToggleSchedule(
|
||||
listSchedule[index].scheduleId,
|
||||
value,
|
||||
);
|
||||
},
|
||||
applyTheme: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
: const EmptySchedule()
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user