import 'package:flutter/material.
dart';
void main() { runApp(RoutineApp()); }
class RoutineApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp(
title: 'Routine App', theme: [Link](), darkTheme: [Link](), themeMode: [Link], home:
HomeScreen(), ); } }
class HomeScreen extends StatefulWidget { @override _HomeScreenState createState() => _HomeScreenState(); }
class _HomeScreenState extends State with SingleTickerProviderStateMixin { late TabController _tabController;
final Map<String, List<Map<String, String>>> weeklyRoutines = { 'Saturday': [], 'Sunday': [], 'Monday': [],
'Tuesday': [], 'Wednesday': [], 'Thursday': [], 'Friday': [], };
@override void initState() { [Link](); _tabController = TabController(length: 7, vsync: this); }
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] = [Link](weeklyRoutines[sourceDay]!); }); } } }
@override Widget build(BuildContext context) { final days = [Link]();
return DefaultTabController( length: 7, child: Scaffold( appBar: AppBar( title: Text('My Weekly Routine'),
bottom: TabBar( controller: _tabController, isScrollable: true, tabs: [Link]((day) => Tab(text:
day)).toList(), ), actions: [ IconButton( icon: Icon([Link]), onPressed: () => [Link]( context,
MaterialPageRoute(builder: (_) => SettingsPage()), ), ), ], ), body: TabBarView( controller: _tabController,
children: [Link]((day) { final routines = weeklyRoutines[day]!; return GestureDetector( onLongPress: () =>
_copyToOtherDays(day), child: [Link]( itemCount: [Link] + 1, itemBuilder: (context, index) {
if (index == [Link]) { return ListTile( title: [Link]( onPressed: () => _addRoutine(day),
icon: Icon([Link]), label: Text('Add More'), ), ); } return ListTile( title:
Text(routines[index]['title']!), subtitle: Text(routines[index]['time']!), trailing: IconButton( icon:
Icon([Link]), onPressed: () => _editRoutine(day, index), ), ); }, ), ); }).toList(), ), ), ); } }
class RoutineDialog extends StatefulWidget { final String? initialTitle; final String? initialTime;
RoutineDialog({[Link], [Link]});
@override _RoutineDialogState createState() => _RoutineDialogState(); }
class _RoutineDialogState extends State { late TextEditingController _titleController; late
TextEditingController _timeController;
@override void initState() { [Link](); _titleController = TextEditingController(text:
[Link]); _timeController = TextEditingController(text: [Link]); }
@override Widget build(BuildContext context) { return AlertDialog( title: Text('Routine Details'), content:
Column( mainAxisSize: [Link], 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: () =>
[Link](context), child: Text('Cancel')), ElevatedButton( onPressed: () { [Link](context, {
'title': _titleController.text, 'time': _timeController.text, }); }, child: Text('Save'), ), ], ); } }
class CopyDialog extends StatefulWidget { final String sourceDay; CopyDialog({required [Link]});
@override _CopyDialogState createState() => _CopyDialogState(); }
class _CopyDialogState extends State { final Map<String, bool> selectedDays = { 'Saturday': false, 'Sunday':
false, 'Monday': false, 'Tuesday': false, 'Wednesday': false, 'Thursday': false, 'Friday': false, };
@override void initState() { [Link](); [Link]([Link]); }
@override Widget build(BuildContext context) { return AlertDialog( title: Text('Copy to:'), content:
SingleChildScrollView( child: Column( children: [Link]((day) { return CheckboxListTile( title:
Text(day), value: selectedDays[day], onChanged: (val) { setState(() => selectedDays[day] = val!); }, );
}).toList(), ), ), actions: [ TextButton(onPressed: () => [Link](context), child: Text('Cancel')),
ElevatedButton( onPressed: () { [Link](context, [Link]((e) => [Link]).map((e) =>
[Link]).toList()); }, child: Text('Copy'), ), ], ); } }
class SettingsPage extends StatefulWidget { @override _SettingsPageState createState() => _SettingsPageState();
}
class _SettingsPageState extends State { ThemeMode _themeMode = [Link];
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Settings')), body:
Column( children: [ ListTile( title: Text('Theme: Light'), leading: Radio( value: [Link], groupValue:
_themeMode, onChanged: (value) => setState(() => _themeMode = value!), ), ), ListTile( title: Text('Theme:
Dark'), leading: Radio( value: [Link], groupValue: _themeMode, onChanged: (value) => setState(() =>
_themeMode = value!), ), ), ListTile( title: Text('Theme: System Default'), leading: Radio( value:
[Link], groupValue: _themeMode, onChanged: (value) => setState(() => _themeMode = value!), ), ),
Divider(), ListTile( title: Text('Upgrade to Premium'), trailing: Icon(Icons.arrow_forward_ios), onTap: () {
[Link](context).showSnackBar( SnackBar(content: Text('Premium feature coming soon!')), ); }, ) ],
), ); } }