init
This commit is contained in:
commit
ffc2051e20
80 files changed
+2915
No files matched your search
@@ -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