RoutineApp FlutterCode
RoutineApp FlutterCode
dart';
class RoutineApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp(
title: 'Routine App', theme: ThemeData.light(), darkTheme: ThemeData.dark(), themeMode: ThemeMode.system, home:
HomeScreen(), ); } }
void *addRoutine(String day) async { final result = await showDialog<Map<String, String>>( context: context,
builder: (*) => RoutineDialog(), ); if (result != null) { setState(() => weeklyRoutines[day]!.add(result)); } }
void *editRoutine(String day, int index) async { final routine = weeklyRoutines[day]![index]; final result =
await showDialog<Map<String, String>>( context: context, builder: (*) => RoutineDialog( initialTitle:
routine['title']!, initialTime: routine['time']!, ), ); if (result != null) { setState(() =>
weeklyRoutines[day]![index] = result); } }
void *copyToOtherDays(String sourceDay) async { final selected = await showDialog<List>( context: context,
builder: (*) => CopyDialog(sourceDay: sourceDay), ); if (selected != null) { for (String day in selected) {
setState(() { weeklyRoutines[day] = List.from(weeklyRoutines[sourceDay]!); }); } } }
class RoutineDialog extends StatefulWidget { final String? initialTitle; final String? initialTime;
RoutineDialog({this.initialTitle, this.initialTime});
@override Widget build(BuildContext context) { return AlertDialog( title: Text('Routine Details'), content:
Column( mainAxisSize: MainAxisSize.min, children: [ TextField( controller: _titleController, decoration:
InputDecoration(labelText: 'Activity Title'), ), TextField( controller: _timeController, decoration:
InputDecoration(labelText: 'Time (e.g., 10:00 AM - 11:00 AM)'), ), ], ), actions: [ TextButton(onPressed: () =>
Navigator.pop(context), child: Text('Cancel')), ElevatedButton( onPressed: () { Navigator.pop(context, {
'title': _titleController.text, 'time': _timeController.text, }); }, child: Text('Save'), ), ], ); } }
class _CopyDialogState extends State { final Map<String, bool> selectedDays = { 'Saturday': false, 'Sunday':
false, 'Monday': false, 'Tuesday': false, 'Wednesday': false, 'Thursday': false, 'Friday': false, };
@override Widget build(BuildContext context) { return AlertDialog( title: Text('Copy to:'), content:
SingleChildScrollView( child: Column( children: selectedDays.keys.map((day) { return CheckboxListTile( title:
Text(day), value: selectedDays[day], onChanged: (val) { setState(() => selectedDays[day] = val!); }, );
}).toList(), ), ), actions: [ TextButton(onPressed: () => Navigator.pop(context), child: Text('Cancel')),
ElevatedButton( onPressed: () { Navigator.pop(context, selectedDays.entries.where((e) => e.value).map((e) =>
e.key).toList()); }, child: Text('Copy'), ), ], ); } }
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Settings')), body:
Column( children: [ ListTile( title: Text('Theme: Light'), leading: Radio( value: ThemeMode.light, groupValue:
_themeMode, onChanged: (value) => setState(() => _themeMode = value!), ), ), ListTile( title: Text('Theme:
Dark'), leading: Radio( value: ThemeMode.dark, groupValue: _themeMode, onChanged: (value) => setState(() =>
_themeMode = value!), ), ), ListTile( title: Text('Theme: System Default'), leading: Radio( value:
ThemeMode.system, groupValue: _themeMode, onChanged: (value) => setState(() => _themeMode = value!), ), ),
Divider(), ListTile( title: Text('Upgrade to Premium'), trailing: Icon(Icons.arrow_forward_ios), onTap: () {
ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('Premium feature coming soon!')), ); }, ) ],
), ); } }