mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-14 17:25:47 +00:00
Bug fixes
This commit is contained in:
@ -1,16 +1,13 @@
|
||||
|
||||
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;
|
||||
@ -25,96 +22,93 @@ class ScheduleListView extends StatelessWidget {
|
||||
@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].function.value ? "ON" : "OFF"}'),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: const BodyMedium(
|
||||
text: '',
|
||||
fontWeight: FontWeight.normal,
|
||||
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)),
|
||||
),
|
||||
trailing: Transform.scale(
|
||||
scale: .8,
|
||||
child: CupertinoSwitch(
|
||||
value: listSchedule[index].enable,
|
||||
onChanged: (value) {
|
||||
onToggleSchedule(
|
||||
listSchedule[index].scheduleId,
|
||||
value,
|
||||
);
|
||||
},
|
||||
applyTheme: true,
|
||||
),
|
||||
),
|
||||
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].function.value ? "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()
|
||||
);
|
||||
)
|
||||
: const EmptySchedule());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user