init
This commit is contained in:
commit
ffc2051e20
80 files changed
+2915
No files matched your search
@@ -0,0 +1,184 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'data/repositories/task_repository.dart';
|
||||
import 'data/services/mock_task_service.dart';
|
||||
import 'ui/core/theme/app_theme.dart';
|
||||
import 'ui/core/theme/theme_controller.dart';
|
||||
import 'ui/core/widgets/responsive_scaffold.dart';
|
||||
import 'ui/features/dashboard/view_models/dashboard_view_model.dart';
|
||||
import 'ui/features/dashboard/views/dashboard_view.dart';
|
||||
import 'ui/features/settings/views/settings_view.dart';
|
||||
|
||||
class MobileApp extends StatefulWidget {
|
||||
const MobileApp({super.key});
|
||||
|
||||
@override
|
||||
State<MobileApp> createState() => _MobileAppState();
|
||||
}
|
||||
|
||||
class _MobileAppState extends State<MobileApp> {
|
||||
late final ThemeController _themeController;
|
||||
late final TaskRepository _taskRepository;
|
||||
late final DashboardViewModel _dashboardViewModel;
|
||||
int _currentTabIndex = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_themeController = ThemeController();
|
||||
_taskRepository = TaskRepository(service: MockTaskService());
|
||||
_dashboardViewModel = DashboardViewModel(repository: _taskRepository);
|
||||
_dashboardViewModel.loadTasks();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_dashboardViewModel.dispose();
|
||||
_themeController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _showAddTaskDialog(BuildContext context) {
|
||||
final titleController = TextEditingController();
|
||||
final descriptionController = TextEditingController();
|
||||
String selectedCategory = 'General';
|
||||
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
return StatefulBuilder(
|
||||
builder: (context, setDialogState) {
|
||||
return AlertDialog(
|
||||
title: const Text('New Task'),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextField(
|
||||
controller: titleController,
|
||||
autofocus: true,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Title',
|
||||
hintText: 'Enter task title',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextField(
|
||||
controller: descriptionController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Description',
|
||||
hintText: 'Optional details',
|
||||
),
|
||||
maxLines: 2,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
DropdownButtonFormField<String>(
|
||||
initialValue: selectedCategory,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Category',
|
||||
),
|
||||
items: const [
|
||||
DropdownMenuItem(value: 'General', child: Text('General')),
|
||||
DropdownMenuItem(value: 'Design', child: Text('Design')),
|
||||
DropdownMenuItem(value: 'Theme', child: Text('Theme')),
|
||||
DropdownMenuItem(value: 'A11y', child: Text('A11y')),
|
||||
],
|
||||
onChanged: (val) {
|
||||
if (val != null) {
|
||||
setDialogState(() => selectedCategory = val);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
final title = titleController.text.trim();
|
||||
if (title.isNotEmpty) {
|
||||
_dashboardViewModel.addTask(
|
||||
title: title,
|
||||
description: descriptionController.text.trim(),
|
||||
category: selectedCategory,
|
||||
);
|
||||
Navigator.of(dialogContext).pop();
|
||||
}
|
||||
},
|
||||
child: const Text('Add Task'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListenableBuilder(
|
||||
listenable: _themeController,
|
||||
builder: (context, _) {
|
||||
return MaterialApp(
|
||||
title: 'Mobile App',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: AppTheme.lightTheme,
|
||||
darkTheme: AppTheme.darkTheme,
|
||||
themeMode: _themeController.themeMode,
|
||||
home: Builder(
|
||||
builder: (innerContext) {
|
||||
final isDarkMode = Theme.of(innerContext).brightness == Brightness.dark;
|
||||
|
||||
return ResponsiveScaffold(
|
||||
selectedIndex: _currentTabIndex,
|
||||
onDestinationSelected: (index) {
|
||||
setState(() => _currentTabIndex = index);
|
||||
},
|
||||
appBarTitle: Text(
|
||||
_currentTabIndex == 0 ? 'Dashboard' : 'Settings',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
isDarkMode ? Icons.light_mode : Icons.dark_mode,
|
||||
),
|
||||
tooltip: isDarkMode ? 'Switch to light mode' : 'Switch to dark mode',
|
||||
onPressed: _themeController.toggleTheme,
|
||||
),
|
||||
],
|
||||
floatingActionButton: _currentTabIndex == 0
|
||||
? FloatingActionButton.extended(
|
||||
onPressed: () => _showAddTaskDialog(innerContext),
|
||||
icon: const Icon(Icons.add),
|
||||
label: const Text('Add Task'),
|
||||
tooltip: 'Create a new task',
|
||||
)
|
||||
: null,
|
||||
destinations: const [
|
||||
NavigationDestinationItem(
|
||||
icon: Icon(Icons.dashboard_outlined),
|
||||
selectedIcon: Icon(Icons.dashboard),
|
||||
label: 'Dashboard',
|
||||
),
|
||||
NavigationDestinationItem(
|
||||
icon: Icon(Icons.settings_outlined),
|
||||
selectedIcon: Icon(Icons.settings),
|
||||
label: 'Settings',
|
||||
),
|
||||
],
|
||||
body: _currentTabIndex == 0
|
||||
? DashboardView(viewModel: _dashboardViewModel)
|
||||
: SettingsView(themeController: _themeController),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import '../../domain/models/task_item.dart';
|
||||
|
||||
class TaskItemModel {
|
||||
const TaskItemModel({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.description,
|
||||
required this.isCompleted,
|
||||
required this.category,
|
||||
required this.createdAt,
|
||||
});
|
||||
|
||||
final String id;
|
||||
final String title;
|
||||
final String description;
|
||||
final bool isCompleted;
|
||||
final String category;
|
||||
final String createdAt;
|
||||
|
||||
factory TaskItemModel.fromJson(Map<String, dynamic> json) {
|
||||
return TaskItemModel(
|
||||
id: json['id'] as String,
|
||||
title: json['title'] as String,
|
||||
description: json['description'] as String? ?? '',
|
||||
isCompleted: json['isCompleted'] as bool? ?? false,
|
||||
category: json['category'] as String? ?? 'General',
|
||||
createdAt: json['createdAt'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'title': title,
|
||||
'description': description,
|
||||
'isCompleted': isCompleted,
|
||||
'category': category,
|
||||
'createdAt': createdAt,
|
||||
};
|
||||
}
|
||||
|
||||
TaskItem toDomain() {
|
||||
return TaskItem(
|
||||
id: id,
|
||||
title: title,
|
||||
description: description,
|
||||
isCompleted: isCompleted,
|
||||
category: category,
|
||||
createdAt: DateTime.tryParse(createdAt) ?? DateTime.now(),
|
||||
);
|
||||
}
|
||||
|
||||
factory TaskItemModel.fromDomain(TaskItem item) {
|
||||
return TaskItemModel(
|
||||
id: item.id,
|
||||
title: item.title,
|
||||
description: item.description,
|
||||
isCompleted: item.isCompleted,
|
||||
category: item.category,
|
||||
createdAt: item.createdAt.toIso8601String(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import '../../domain/models/task_item.dart';
|
||||
import '../models/task_item_model.dart';
|
||||
import '../services/mock_task_service.dart';
|
||||
|
||||
class TaskRepository {
|
||||
TaskRepository({required this._service});
|
||||
|
||||
final MockTaskService _service;
|
||||
List<TaskItem>? _cachedTasks;
|
||||
|
||||
Future<List<TaskItem>> getTasks({bool forceRefresh = false}) async {
|
||||
if (!forceRefresh && _cachedTasks != null) {
|
||||
return _cachedTasks!;
|
||||
}
|
||||
final models = await _service.fetchTasks();
|
||||
_cachedTasks = models.map((m) => m.toDomain()).toList();
|
||||
return _cachedTasks!;
|
||||
}
|
||||
|
||||
Future<TaskItem> createTask({
|
||||
required String title,
|
||||
required String description,
|
||||
required String category,
|
||||
}) async {
|
||||
final newItem = TaskItem(
|
||||
id: DateTime.now().millisecondsSinceEpoch.toString(),
|
||||
title: title,
|
||||
description: description,
|
||||
category: category,
|
||||
createdAt: DateTime.now(),
|
||||
);
|
||||
|
||||
await _service.addTask(TaskItemModel.fromDomain(newItem));
|
||||
_cachedTasks?.insert(0, newItem);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
Future<void> toggleTaskStatus(TaskItem item) async {
|
||||
final updated = item.copyWith(isCompleted: !item.isCompleted);
|
||||
await _service.updateTask(TaskItemModel.fromDomain(updated));
|
||||
if (_cachedTasks != null) {
|
||||
final index = _cachedTasks!.indexWhere((t) => t.id == item.id);
|
||||
if (index != -1) {
|
||||
_cachedTasks![index] = updated;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> removeTask(String id) async {
|
||||
await _service.deleteTask(id);
|
||||
_cachedTasks?.removeWhere((t) => t.id == id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import '../models/task_item_model.dart';
|
||||
|
||||
class MockTaskService {
|
||||
final List<Map<String, dynamic>> _rawStorage = [
|
||||
{
|
||||
'id': '1',
|
||||
'title': 'Explore Material 3 Layouts',
|
||||
'description': 'Test responsiveness on both iPhone and Android screen sizes.',
|
||||
'isCompleted': true,
|
||||
'category': 'Design',
|
||||
'createdAt': DateTime.now().subtract(const Duration(hours: 4)).toIso8601String(),
|
||||
},
|
||||
{
|
||||
'id': '2',
|
||||
'title': 'Test Light & Dark Modes',
|
||||
'description': 'Ensure contrast and colors look great in both themes.',
|
||||
'isCompleted': false,
|
||||
'category': 'Theme',
|
||||
'createdAt': DateTime.now().subtract(const Duration(hours: 2)).toIso8601String(),
|
||||
},
|
||||
{
|
||||
'id': '3',
|
||||
'title': 'Verify Accessibility & Touch Targets',
|
||||
'description': 'Ensure tap targets adhere to >= 48x48 logical pixels with semantic labels.',
|
||||
'isCompleted': false,
|
||||
'category': 'A11y',
|
||||
'createdAt': DateTime.now().subtract(const Duration(minutes: 30)).toIso8601String(),
|
||||
},
|
||||
];
|
||||
|
||||
Future<List<TaskItemModel>> fetchTasks() async {
|
||||
// Simulate brief network/storage delay
|
||||
await Future.delayed(const Duration(milliseconds: 250));
|
||||
return _rawStorage.map(TaskItemModel.fromJson).toList();
|
||||
}
|
||||
|
||||
Future<TaskItemModel> addTask(TaskItemModel task) async {
|
||||
await Future.delayed(const Duration(milliseconds: 150));
|
||||
_rawStorage.insert(0, task.toJson());
|
||||
return task;
|
||||
}
|
||||
|
||||
Future<void> updateTask(TaskItemModel task) async {
|
||||
await Future.delayed(const Duration(milliseconds: 150));
|
||||
final index = _rawStorage.indexWhere((e) => e['id'] == task.id);
|
||||
if (index != -1) {
|
||||
_rawStorage[index] = task.toJson();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteTask(String id) async {
|
||||
await Future.delayed(const Duration(milliseconds: 150));
|
||||
_rawStorage.removeWhere((e) => e['id'] == id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
class TaskItem {
|
||||
const TaskItem({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.description,
|
||||
this.isCompleted = false,
|
||||
required this.category,
|
||||
required this.createdAt,
|
||||
});
|
||||
|
||||
final String id;
|
||||
final String title;
|
||||
final String description;
|
||||
final bool isCompleted;
|
||||
final String category;
|
||||
final DateTime createdAt;
|
||||
|
||||
TaskItem copyWith({
|
||||
String? id,
|
||||
String? title,
|
||||
String? description,
|
||||
bool? isCompleted,
|
||||
String? category,
|
||||
DateTime? createdAt,
|
||||
}) {
|
||||
return TaskItem(
|
||||
id: id ?? this.id,
|
||||
title: title ?? this.title,
|
||||
description: description ?? this.description,
|
||||
isCompleted: isCompleted ?? this.isCompleted,
|
||||
category: category ?? this.category,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'app.dart';
|
||||
|
||||
void main() {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
runApp(const MobileApp());
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AppTheme {
|
||||
static const Color primarySeed = Color(0xFF006686);
|
||||
|
||||
static ThemeData lightTheme = ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: primarySeed,
|
||||
brightness: Brightness.light,
|
||||
),
|
||||
appBarTheme: const AppBarTheme(
|
||||
centerTitle: false,
|
||||
elevation: 0,
|
||||
),
|
||||
cardTheme: CardThemeData(
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
side: BorderSide(
|
||||
color: Colors.grey.withAlpha(50),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
static ThemeData darkTheme = ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: primarySeed,
|
||||
brightness: Brightness.dark,
|
||||
),
|
||||
appBarTheme: const AppBarTheme(
|
||||
centerTitle: false,
|
||||
elevation: 0,
|
||||
),
|
||||
cardTheme: CardThemeData(
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
side: BorderSide(
|
||||
color: Colors.white.withAlpha(25),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ThemeController extends ChangeNotifier {
|
||||
ThemeMode _themeMode = ThemeMode.system;
|
||||
|
||||
ThemeMode get themeMode => _themeMode;
|
||||
|
||||
void setThemeMode(ThemeMode mode) {
|
||||
if (_themeMode == mode) return;
|
||||
_themeMode = mode;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void toggleTheme() {
|
||||
if (_themeMode == ThemeMode.dark) {
|
||||
setThemeMode(ThemeMode.light);
|
||||
} else {
|
||||
setThemeMode(ThemeMode.dark);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
const double largeScreenMinWidth = 640.0;
|
||||
|
||||
class NavigationDestinationItem {
|
||||
const NavigationDestinationItem({
|
||||
required this.icon,
|
||||
required this.selectedIcon,
|
||||
required this.label,
|
||||
});
|
||||
|
||||
final Widget icon;
|
||||
final Widget selectedIcon;
|
||||
final String label;
|
||||
}
|
||||
|
||||
class ResponsiveScaffold extends StatelessWidget {
|
||||
const ResponsiveScaffold({
|
||||
super.key,
|
||||
required this.selectedIndex,
|
||||
required this.onDestinationSelected,
|
||||
required this.destinations,
|
||||
required this.body,
|
||||
this.appBarTitle,
|
||||
this.actions,
|
||||
this.floatingActionButton,
|
||||
});
|
||||
|
||||
final int selectedIndex;
|
||||
final ValueChanged<int> onDestinationSelected;
|
||||
final List<NavigationDestinationItem> destinations;
|
||||
final Widget body;
|
||||
final Widget? appBarTitle;
|
||||
final List<Widget>? actions;
|
||||
final Widget? floatingActionButton;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final isLargeScreen = constraints.maxWidth >= largeScreenMinWidth;
|
||||
|
||||
if (isLargeScreen) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: appBarTitle,
|
||||
actions: actions,
|
||||
),
|
||||
floatingActionButton: floatingActionButton,
|
||||
body: Row(
|
||||
children: [
|
||||
NavigationRail(
|
||||
selectedIndex: selectedIndex,
|
||||
onDestinationSelected: onDestinationSelected,
|
||||
labelType: NavigationRailLabelType.all,
|
||||
destinations: destinations.map((d) {
|
||||
return NavigationRailDestination(
|
||||
icon: d.icon,
|
||||
selectedIcon: d.selectedIcon,
|
||||
label: Text(d.label),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
const VerticalDivider(thickness: 1, width: 1),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 960),
|
||||
child: body,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: appBarTitle,
|
||||
actions: actions,
|
||||
),
|
||||
body: Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 640),
|
||||
child: body,
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: NavigationBar(
|
||||
selectedIndex: selectedIndex,
|
||||
onDestinationSelected: onDestinationSelected,
|
||||
destinations: destinations.map((d) {
|
||||
return NavigationDestination(
|
||||
icon: d.icon,
|
||||
selectedIcon: d.selectedIcon,
|
||||
label: d.label,
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
floatingActionButton: floatingActionButton,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import '../../../../data/repositories/task_repository.dart';
|
||||
import '../../../../domain/models/task_item.dart';
|
||||
|
||||
class DashboardViewModel extends ChangeNotifier {
|
||||
DashboardViewModel({required this._repository});
|
||||
|
||||
final TaskRepository _repository;
|
||||
|
||||
List<TaskItem> _tasks = [];
|
||||
bool _isLoading = false;
|
||||
String _selectedCategory = 'All';
|
||||
|
||||
List<TaskItem> get tasks {
|
||||
if (_selectedCategory == 'All') {
|
||||
return List.unmodifiable(_tasks);
|
||||
}
|
||||
return List.unmodifiable(
|
||||
_tasks.where((t) => t.category == _selectedCategory),
|
||||
);
|
||||
}
|
||||
|
||||
bool get isLoading => _isLoading;
|
||||
String get selectedCategory => _selectedCategory;
|
||||
|
||||
int get totalCount => _tasks.length;
|
||||
int get completedCount => _tasks.where((t) => t.isCompleted).length;
|
||||
double get completionProgress =>
|
||||
_tasks.isEmpty ? 0.0 : completedCount / totalCount;
|
||||
|
||||
List<String> get availableCategories => [
|
||||
'All',
|
||||
'Design',
|
||||
'Theme',
|
||||
'A11y',
|
||||
'General',
|
||||
];
|
||||
|
||||
Future<void> loadTasks() async {
|
||||
_isLoading = true;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
_tasks = await _repository.getTasks();
|
||||
} finally {
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
void setCategoryFilter(String category) {
|
||||
if (_selectedCategory == category) return;
|
||||
_selectedCategory = category;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> toggleTaskCompletion(TaskItem item) async {
|
||||
await _repository.toggleTaskStatus(item);
|
||||
_tasks = await _repository.getTasks();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> addTask({
|
||||
required String title,
|
||||
required String description,
|
||||
required String category,
|
||||
}) async {
|
||||
await _repository.createTask(
|
||||
title: title,
|
||||
description: description,
|
||||
category: category,
|
||||
);
|
||||
_tasks = await _repository.getTasks();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> deleteTask(String id) async {
|
||||
await _repository.removeTask(id);
|
||||
_tasks = await _repository.getTasks();
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../domain/models/task_item.dart';
|
||||
import '../view_models/dashboard_view_model.dart';
|
||||
|
||||
class DashboardView extends StatelessWidget {
|
||||
const DashboardView({super.key, required this.viewModel});
|
||||
|
||||
final DashboardViewModel viewModel;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListenableBuilder(
|
||||
listenable: viewModel,
|
||||
builder: (context, _) {
|
||||
if (viewModel.isLoading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
final tasks = viewModel.tasks;
|
||||
|
||||
return ListView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
|
||||
children: [
|
||||
_buildSummaryCard(context),
|
||||
const SizedBox(height: 16),
|
||||
_buildCategoryFilter(context),
|
||||
const SizedBox(height: 12),
|
||||
if (tasks.isEmpty)
|
||||
_buildEmptyState(context)
|
||||
else
|
||||
...tasks.map((task) => _buildTaskCard(context, task)),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSummaryCard(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
final textTheme = Theme.of(context).textTheme;
|
||||
|
||||
return Card(
|
||||
color: colorScheme.surfaceContainerHighest.withAlpha(128),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Task Progress',
|
||||
style: textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${viewModel.completedCount}/${viewModel.totalCount}',
|
||||
style: textTheme.titleMedium?.copyWith(
|
||||
color: colorScheme.primary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: LinearProgressIndicator(
|
||||
value: viewModel.completionProgress,
|
||||
minHeight: 10,
|
||||
backgroundColor: colorScheme.surfaceContainerHighest,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'${(viewModel.completionProgress * 100).round()}% completed',
|
||||
style: textTheme.bodySmall?.copyWith(
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCategoryFilter(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: viewModel.availableCategories.map((category) {
|
||||
final isSelected = viewModel.selectedCategory == category;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 8.0),
|
||||
child: FilterChip(
|
||||
label: Text(category),
|
||||
selected: isSelected,
|
||||
onSelected: (_) => viewModel.setCategoryFilter(category),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTaskCard(BuildContext context, TaskItem task) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Card(
|
||||
margin: const EdgeInsets.only(bottom: 8.0),
|
||||
child: ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
leading: Checkbox(
|
||||
value: task.isCompleted,
|
||||
onChanged: (_) => viewModel.toggleTaskCompletion(task),
|
||||
),
|
||||
title: Text(
|
||||
task.title,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
decoration: task.isCompleted
|
||||
? TextDecoration.lineThrough
|
||||
: TextDecoration.none,
|
||||
color: task.isCompleted ? colorScheme.outline : null,
|
||||
),
|
||||
),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (task.description.isNotEmpty) ...[
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
task.description,
|
||||
style: TextStyle(
|
||||
color: task.isCompleted ? colorScheme.outline : null,
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 6),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.secondaryContainer,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
task.category,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: colorScheme.onSecondaryContainer,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.delete_outline),
|
||||
tooltip: 'Delete task',
|
||||
onPressed: () => viewModel.deleteTask(task.id),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEmptyState(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 48.0),
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.done_all,
|
||||
size: 56,
|
||||
color: theme.colorScheme.outlineVariant,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'No tasks in this category',
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../core/theme/theme_controller.dart';
|
||||
|
||||
class SettingsView extends StatelessWidget {
|
||||
const SettingsView({super.key, required this.themeController});
|
||||
|
||||
final ThemeController themeController;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return ListenableBuilder(
|
||||
listenable: themeController,
|
||||
builder: (context, _) {
|
||||
return ListView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
|
||||
children: [
|
||||
Text(
|
||||
'Appearance',
|
||||
style: theme.textTheme.titleSmall?.copyWith(
|
||||
color: theme.colorScheme.primary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Card(
|
||||
child: RadioGroup<ThemeMode>(
|
||||
groupValue: themeController.themeMode,
|
||||
onChanged: (mode) {
|
||||
if (mode != null) themeController.setThemeMode(mode);
|
||||
},
|
||||
child: const Column(
|
||||
children: [
|
||||
RadioListTile<ThemeMode>(
|
||||
title: Text('System Default'),
|
||||
subtitle: Text('Follow operating system theme'),
|
||||
secondary: Icon(Icons.brightness_auto_outlined),
|
||||
value: ThemeMode.system,
|
||||
),
|
||||
Divider(height: 1),
|
||||
RadioListTile<ThemeMode>(
|
||||
title: Text('Light Mode'),
|
||||
secondary: Icon(Icons.light_mode_outlined),
|
||||
value: ThemeMode.light,
|
||||
),
|
||||
Divider(height: 1),
|
||||
RadioListTile<ThemeMode>(
|
||||
title: Text('Dark Mode'),
|
||||
secondary: Icon(Icons.dark_mode_outlined),
|
||||
value: ThemeMode.dark,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
'About App',
|
||||
style: theme.textTheme.titleSmall?.copyWith(
|
||||
color: theme.colorScheme.primary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Card(
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: Icon(Icons.phone_android_outlined),
|
||||
title: Text('Supported Platforms'),
|
||||
subtitle: Text('Android & iOS (iPhone/iPad)'),
|
||||
),
|
||||
Divider(height: 1),
|
||||
ListTile(
|
||||
leading: Icon(Icons.layers_outlined),
|
||||
title: Text('Architecture'),
|
||||
subtitle: Text('Clean Architecture (Data, Domain, Presentation)'),
|
||||
),
|
||||
Divider(height: 1),
|
||||
ListTile(
|
||||
leading: Icon(Icons.palette_outlined),
|
||||
title: Text('Design System'),
|
||||
subtitle: Text('Material Design 3 with Adaptive Layouts'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user