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,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user