|
|
@ -3,14 +3,20 @@
|
|
|
|
// found in the LICENSE file.
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'package:flutter/scheduler.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import 'color_palettes_screen.dart';
|
|
|
|
import 'color_palettes_screen.dart';
|
|
|
|
import 'component_screen.dart';
|
|
|
|
import 'component_screen.dart';
|
|
|
|
import 'elevation_screen.dart';
|
|
|
|
import 'elevation_screen.dart';
|
|
|
|
import 'typography_screen.dart';
|
|
|
|
import 'typography_screen.dart';
|
|
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
void main() {
|
|
|
|
runApp(const MaterialApp(
|
|
|
|
runApp(
|
|
|
|
debugShowCheckedModeBanner: false, home: Material3Demo()));
|
|
|
|
const MaterialApp(
|
|
|
|
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
|
|
|
|
home: Material3Demo(),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class Material3Demo extends StatefulWidget {
|
|
|
|
class Material3Demo extends StatefulWidget {
|
|
|
@ -61,17 +67,25 @@ class _Material3DemoState extends State<Material3Demo>
|
|
|
|
bool showMediumSizeLayout = false;
|
|
|
|
bool showMediumSizeLayout = false;
|
|
|
|
bool showLargeSizeLayout = false;
|
|
|
|
bool showLargeSizeLayout = false;
|
|
|
|
bool useMaterial3 = true;
|
|
|
|
bool useMaterial3 = true;
|
|
|
|
bool useLightMode = true;
|
|
|
|
ThemeMode themeMode = ThemeMode.system;
|
|
|
|
|
|
|
|
bool get useLightMode {
|
|
|
|
|
|
|
|
switch (themeMode) {
|
|
|
|
|
|
|
|
case ThemeMode.system:
|
|
|
|
|
|
|
|
return SchedulerBinding.instance.window.platformBrightness ==
|
|
|
|
|
|
|
|
Brightness.light;
|
|
|
|
|
|
|
|
case ThemeMode.light:
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case ThemeMode.dark:
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ColorSeed colorSelected = ColorSeed.baseColor;
|
|
|
|
ColorSeed colorSelected = ColorSeed.baseColor;
|
|
|
|
int screenIndex = ScreenSelected.component.value;
|
|
|
|
int screenIndex = ScreenSelected.component.value;
|
|
|
|
|
|
|
|
|
|
|
|
late ThemeData themeData;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
initState() {
|
|
|
|
initState() {
|
|
|
|
super.initState();
|
|
|
|
super.initState();
|
|
|
|
themeData = updateThemes(colorSelected.color, useMaterial3, useLightMode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
controller = AnimationController(
|
|
|
|
controller = AnimationController(
|
|
|
|
duration: Duration(milliseconds: transitionLength.toInt() * 2),
|
|
|
|
duration: Duration(milliseconds: transitionLength.toInt() * 2),
|
|
|
|
value: 0,
|
|
|
|
value: 0,
|
|
|
@ -121,38 +135,27 @@ class _Material3DemoState extends State<Material3Demo>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ThemeData updateThemes(
|
|
|
|
|
|
|
|
Color colorSelected, bool useMaterial3, bool useLightMode) {
|
|
|
|
|
|
|
|
return ThemeData(
|
|
|
|
|
|
|
|
colorSchemeSeed: colorSelected,
|
|
|
|
|
|
|
|
useMaterial3: useMaterial3,
|
|
|
|
|
|
|
|
brightness: useLightMode ? Brightness.light : Brightness.dark);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void handleScreenChanged(int screenSelected) {
|
|
|
|
void handleScreenChanged(int screenSelected) {
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
screenIndex = screenSelected;
|
|
|
|
screenIndex = screenSelected;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void handleBrightnessChange() {
|
|
|
|
void handleBrightnessChange(bool useLightMode) {
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
useLightMode = !useLightMode;
|
|
|
|
themeMode = useLightMode ? ThemeMode.light : ThemeMode.dark;
|
|
|
|
themeData = updateThemes(colorSelected.color, useMaterial3, useLightMode);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void handleMaterialVersionChange() {
|
|
|
|
void handleMaterialVersionChange() {
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
useMaterial3 = !useMaterial3;
|
|
|
|
useMaterial3 = !useMaterial3;
|
|
|
|
themeData = updateThemes(colorSelected.color, useMaterial3, useLightMode);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void handleColorSelect(int value) {
|
|
|
|
void handleColorSelect(int value) {
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
colorSelected = ColorSeed.values[value];
|
|
|
|
colorSelected = ColorSeed.values[value];
|
|
|
|
themeData = updateThemes(colorSelected.color, useMaterial3, useLightMode);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -161,14 +164,17 @@ class _Material3DemoState extends State<Material3Demo>
|
|
|
|
switch (screenSelected) {
|
|
|
|
switch (screenSelected) {
|
|
|
|
case ScreenSelected.component:
|
|
|
|
case ScreenSelected.component:
|
|
|
|
return Expanded(
|
|
|
|
return Expanded(
|
|
|
|
child: OneTwoTransition(
|
|
|
|
child: OneTwoTransition(
|
|
|
|
animation: railAnimation,
|
|
|
|
animation: railAnimation,
|
|
|
|
one: FirstComponentList(
|
|
|
|
one: FirstComponentList(
|
|
|
|
showNavBottomBar: showNavBarExample,
|
|
|
|
showNavBottomBar: showNavBarExample,
|
|
|
|
scaffoldKey: scaffoldKey,
|
|
|
|
scaffoldKey: scaffoldKey,
|
|
|
|
showSecondList:
|
|
|
|
showSecondList: showMediumSizeLayout || showLargeSizeLayout),
|
|
|
|
showMediumSizeLayout || showLargeSizeLayout),
|
|
|
|
two: SecondComponentList(
|
|
|
|
two: const SecondComponentList()));
|
|
|
|
scaffoldKey: scaffoldKey,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
case ScreenSelected.color:
|
|
|
|
case ScreenSelected.color:
|
|
|
|
return const ColorPalettesScreen();
|
|
|
|
return const ColorPalettesScreen();
|
|
|
|
case ScreenSelected.typography:
|
|
|
|
case ScreenSelected.typography:
|
|
|
@ -183,68 +189,21 @@ class _Material3DemoState extends State<Material3Demo>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget brightnessButton({bool showTooltipBelow = true}) => Tooltip(
|
|
|
|
|
|
|
|
preferBelow: showTooltipBelow,
|
|
|
|
|
|
|
|
message: 'Toggle brightness',
|
|
|
|
|
|
|
|
child: IconButton(
|
|
|
|
|
|
|
|
icon: useLightMode
|
|
|
|
|
|
|
|
? const Icon(Icons.wb_sunny_outlined)
|
|
|
|
|
|
|
|
: const Icon(Icons.wb_sunny),
|
|
|
|
|
|
|
|
onPressed: handleBrightnessChange,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Widget material3Button({bool showTooltipBelow = true}) => Tooltip(
|
|
|
|
|
|
|
|
preferBelow: showTooltipBelow,
|
|
|
|
|
|
|
|
message: 'Switch to Material ${useMaterial3 ? 2 : 3}',
|
|
|
|
|
|
|
|
child: IconButton(
|
|
|
|
|
|
|
|
icon: useMaterial3
|
|
|
|
|
|
|
|
? const Icon(Icons.filter_3)
|
|
|
|
|
|
|
|
: const Icon(Icons.filter_2),
|
|
|
|
|
|
|
|
onPressed: handleMaterialVersionChange,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Widget colorSeedButton(Icon icon) => PopupMenuButton(
|
|
|
|
|
|
|
|
icon: icon,
|
|
|
|
|
|
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
|
|
|
|
|
|
itemBuilder: (context) {
|
|
|
|
|
|
|
|
return List.generate(ColorSeed.values.length, (index) {
|
|
|
|
|
|
|
|
ColorSeed currentColor = ColorSeed.values[index];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return PopupMenuItem(
|
|
|
|
|
|
|
|
value: index,
|
|
|
|
|
|
|
|
child: Wrap(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Padding(
|
|
|
|
|
|
|
|
padding: const EdgeInsets.only(left: 10),
|
|
|
|
|
|
|
|
child: Icon(
|
|
|
|
|
|
|
|
currentColor == colorSelected
|
|
|
|
|
|
|
|
? Icons.color_lens
|
|
|
|
|
|
|
|
: Icons.color_lens_outlined,
|
|
|
|
|
|
|
|
color: currentColor.color,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Padding(
|
|
|
|
|
|
|
|
padding: const EdgeInsets.only(left: 20),
|
|
|
|
|
|
|
|
child: Text(currentColor.label),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onSelected: handleColorSelect,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PreferredSizeWidget createAppBar() {
|
|
|
|
PreferredSizeWidget createAppBar() {
|
|
|
|
return AppBar(
|
|
|
|
return AppBar(
|
|
|
|
title: useMaterial3 ? const Text('Material 3') : const Text('Material 2'),
|
|
|
|
title: useMaterial3 ? const Text('Material 3') : const Text('Material 2'),
|
|
|
|
actions: !showMediumSizeLayout && !showLargeSizeLayout
|
|
|
|
actions: !showMediumSizeLayout && !showLargeSizeLayout
|
|
|
|
? [
|
|
|
|
? [
|
|
|
|
brightnessButton(),
|
|
|
|
_BrightnessButton(
|
|
|
|
material3Button(),
|
|
|
|
handleBrightnessChange: handleBrightnessChange,
|
|
|
|
colorSeedButton(const Icon(Icons.more_vert)),
|
|
|
|
),
|
|
|
|
|
|
|
|
_Material3Button(
|
|
|
|
|
|
|
|
handleMaterialVersionChange: handleMaterialVersionChange,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
_ColorSeedButton(
|
|
|
|
|
|
|
|
handleColorSelect: handleColorSelect,
|
|
|
|
|
|
|
|
colorSelected: colorSelected,
|
|
|
|
|
|
|
|
),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
: [Container()],
|
|
|
|
: [Container()],
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -263,8 +222,8 @@ class _Material3DemoState extends State<Material3Demo>
|
|
|
|
Expanded(child: Container()),
|
|
|
|
Expanded(child: Container()),
|
|
|
|
Switch(
|
|
|
|
Switch(
|
|
|
|
value: useLightMode,
|
|
|
|
value: useLightMode,
|
|
|
|
onChanged: (_) {
|
|
|
|
onChanged: (value) {
|
|
|
|
handleBrightnessChange();
|
|
|
|
handleBrightnessChange(value);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
@ -289,8 +248,11 @@ class _Material3DemoState extends State<Material3Demo>
|
|
|
|
children: List.generate(
|
|
|
|
children: List.generate(
|
|
|
|
ColorSeed.values.length,
|
|
|
|
ColorSeed.values.length,
|
|
|
|
(i) => IconButton(
|
|
|
|
(i) => IconButton(
|
|
|
|
icon: const Icon(Icons.circle),
|
|
|
|
icon: const Icon(Icons.radio_button_unchecked),
|
|
|
|
color: ColorSeed.values[i].color,
|
|
|
|
color: ColorSeed.values[i].color,
|
|
|
|
|
|
|
|
isSelected:
|
|
|
|
|
|
|
|
colorSelected.color == ColorSeed.values[i].color,
|
|
|
|
|
|
|
|
selectedIcon: const Icon(Icons.circle),
|
|
|
|
onPressed: () {
|
|
|
|
onPressed: () {
|
|
|
|
handleColorSelect(i);
|
|
|
|
handleColorSelect(i);
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -304,9 +266,24 @@ class _Material3DemoState extends State<Material3Demo>
|
|
|
|
Widget _trailingActions() => Column(
|
|
|
|
Widget _trailingActions() => Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Flexible(child: brightnessButton(showTooltipBelow: false)),
|
|
|
|
Flexible(
|
|
|
|
Flexible(child: material3Button(showTooltipBelow: false)),
|
|
|
|
child: _BrightnessButton(
|
|
|
|
Flexible(child: colorSeedButton(const Icon(Icons.more_horiz))),
|
|
|
|
handleBrightnessChange: handleBrightnessChange,
|
|
|
|
|
|
|
|
showTooltipBelow: false,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Flexible(
|
|
|
|
|
|
|
|
child: _Material3Button(
|
|
|
|
|
|
|
|
handleMaterialVersionChange: handleMaterialVersionChange,
|
|
|
|
|
|
|
|
showTooltipBelow: false,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Flexible(
|
|
|
|
|
|
|
|
child: _ColorSeedButton(
|
|
|
|
|
|
|
|
handleColorSelect: handleColorSelect,
|
|
|
|
|
|
|
|
colorSelected: colorSelected,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
@ -315,49 +292,159 @@ class _Material3DemoState extends State<Material3Demo>
|
|
|
|
return MaterialApp(
|
|
|
|
return MaterialApp(
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
title: 'Material 3',
|
|
|
|
title: 'Material 3',
|
|
|
|
themeMode: useLightMode ? ThemeMode.light : ThemeMode.dark,
|
|
|
|
themeMode: themeMode,
|
|
|
|
theme: themeData,
|
|
|
|
theme: ThemeData(
|
|
|
|
|
|
|
|
colorSchemeSeed: colorSelected.color,
|
|
|
|
|
|
|
|
useMaterial3: useMaterial3,
|
|
|
|
|
|
|
|
brightness: Brightness.light,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
darkTheme: ThemeData(
|
|
|
|
|
|
|
|
colorSchemeSeed: colorSelected.color,
|
|
|
|
|
|
|
|
useMaterial3: useMaterial3,
|
|
|
|
|
|
|
|
brightness: Brightness.dark,
|
|
|
|
|
|
|
|
),
|
|
|
|
home: AnimatedBuilder(
|
|
|
|
home: AnimatedBuilder(
|
|
|
|
animation: controller,
|
|
|
|
animation: controller,
|
|
|
|
builder: (context, child) {
|
|
|
|
builder: (context, child) {
|
|
|
|
return NavigationTransition(
|
|
|
|
return NavigationTransition(
|
|
|
|
scaffoldKey: scaffoldKey,
|
|
|
|
scaffoldKey: scaffoldKey,
|
|
|
|
animationController: controller,
|
|
|
|
animationController: controller,
|
|
|
|
railAnimation: railAnimation,
|
|
|
|
railAnimation: railAnimation,
|
|
|
|
appBar: createAppBar(),
|
|
|
|
appBar: createAppBar(),
|
|
|
|
body: createScreenFor(
|
|
|
|
body: createScreenFor(
|
|
|
|
ScreenSelected.values[screenIndex], controller.value == 1),
|
|
|
|
ScreenSelected.values[screenIndex], controller.value == 1),
|
|
|
|
navigationRail: NavigationRail(
|
|
|
|
navigationRail: NavigationRail(
|
|
|
|
extended: showLargeSizeLayout,
|
|
|
|
extended: showLargeSizeLayout,
|
|
|
|
destinations: navRailDestinations,
|
|
|
|
destinations: navRailDestinations,
|
|
|
|
selectedIndex: screenIndex,
|
|
|
|
selectedIndex: screenIndex,
|
|
|
|
onDestinationSelected: (index) {
|
|
|
|
onDestinationSelected: (index) {
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
screenIndex = index;
|
|
|
|
screenIndex = index;
|
|
|
|
handleScreenChanged(screenIndex);
|
|
|
|
handleScreenChanged(screenIndex);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
trailing: Expanded(
|
|
|
|
trailing: Expanded(
|
|
|
|
child: Padding(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.only(bottom: 20),
|
|
|
|
padding: const EdgeInsets.only(bottom: 20),
|
|
|
|
child: showLargeSizeLayout
|
|
|
|
child: showLargeSizeLayout
|
|
|
|
? _expandedTrailingActions()
|
|
|
|
? _expandedTrailingActions()
|
|
|
|
: _trailingActions(),
|
|
|
|
: _trailingActions(),
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
navigationBar: NavigationBars(
|
|
|
|
),
|
|
|
|
onSelectItem: (index) {
|
|
|
|
navigationBar: NavigationBars(
|
|
|
|
setState(() {
|
|
|
|
onSelectItem: (index) {
|
|
|
|
screenIndex = index;
|
|
|
|
setState(() {
|
|
|
|
handleScreenChanged(screenIndex);
|
|
|
|
screenIndex = index;
|
|
|
|
});
|
|
|
|
handleScreenChanged(screenIndex);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
selectedIndex: screenIndex,
|
|
|
|
},
|
|
|
|
isExampleBar: false,
|
|
|
|
selectedIndex: screenIndex,
|
|
|
|
),
|
|
|
|
isExampleBar: false,
|
|
|
|
);
|
|
|
|
),
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _BrightnessButton extends StatelessWidget {
|
|
|
|
|
|
|
|
const _BrightnessButton({
|
|
|
|
|
|
|
|
required this.handleBrightnessChange,
|
|
|
|
|
|
|
|
this.showTooltipBelow = true,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final Function handleBrightnessChange;
|
|
|
|
|
|
|
|
final bool showTooltipBelow;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
|
|
final isBright = Theme.of(context).brightness == Brightness.light;
|
|
|
|
|
|
|
|
return Tooltip(
|
|
|
|
|
|
|
|
preferBelow: showTooltipBelow,
|
|
|
|
|
|
|
|
message: 'Toggle brightness',
|
|
|
|
|
|
|
|
child: IconButton(
|
|
|
|
|
|
|
|
icon: isBright
|
|
|
|
|
|
|
|
? const Icon(Icons.dark_mode_outlined)
|
|
|
|
|
|
|
|
: const Icon(Icons.light_mode_outlined),
|
|
|
|
|
|
|
|
onPressed: () => handleBrightnessChange(!isBright),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _Material3Button extends StatelessWidget {
|
|
|
|
|
|
|
|
const _Material3Button({
|
|
|
|
|
|
|
|
required this.handleMaterialVersionChange,
|
|
|
|
|
|
|
|
this.showTooltipBelow = true,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final void Function() handleMaterialVersionChange;
|
|
|
|
|
|
|
|
final bool showTooltipBelow;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
|
|
final useMaterial3 = Theme.of(context).useMaterial3;
|
|
|
|
|
|
|
|
return Tooltip(
|
|
|
|
|
|
|
|
preferBelow: showTooltipBelow,
|
|
|
|
|
|
|
|
message: 'Switch to Material ${useMaterial3 ? 2 : 3}',
|
|
|
|
|
|
|
|
child: IconButton(
|
|
|
|
|
|
|
|
icon: useMaterial3
|
|
|
|
|
|
|
|
? const Icon(Icons.filter_2)
|
|
|
|
|
|
|
|
: const Icon(Icons.filter_3),
|
|
|
|
|
|
|
|
onPressed: handleMaterialVersionChange,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _ColorSeedButton extends StatelessWidget {
|
|
|
|
|
|
|
|
const _ColorSeedButton({
|
|
|
|
|
|
|
|
required this.handleColorSelect,
|
|
|
|
|
|
|
|
required this.colorSelected,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final void Function(int) handleColorSelect;
|
|
|
|
|
|
|
|
final ColorSeed colorSelected;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
|
|
return PopupMenuButton(
|
|
|
|
|
|
|
|
icon: Icon(
|
|
|
|
|
|
|
|
Icons.palette_outlined,
|
|
|
|
|
|
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
tooltip: 'Select a seed color',
|
|
|
|
|
|
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
|
|
|
|
|
|
itemBuilder: (context) {
|
|
|
|
|
|
|
|
return List.generate(ColorSeed.values.length, (index) {
|
|
|
|
|
|
|
|
ColorSeed currentColor = ColorSeed.values[index];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return PopupMenuItem(
|
|
|
|
|
|
|
|
value: index,
|
|
|
|
|
|
|
|
enabled: currentColor != colorSelected,
|
|
|
|
|
|
|
|
child: Wrap(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Padding(
|
|
|
|
|
|
|
|
padding: const EdgeInsets.only(left: 10),
|
|
|
|
|
|
|
|
child: Icon(
|
|
|
|
|
|
|
|
currentColor == colorSelected
|
|
|
|
|
|
|
|
? Icons.color_lens
|
|
|
|
|
|
|
|
: Icons.color_lens_outlined,
|
|
|
|
|
|
|
|
color: currentColor.color,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
Padding(
|
|
|
|
|
|
|
|
padding: const EdgeInsets.only(left: 20),
|
|
|
|
|
|
|
|
child: Text(currentColor.label),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onSelected: handleColorSelect,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -421,9 +508,6 @@ class _NavigationTransitionState extends State<NavigationTransition> {
|
|
|
|
backgroundColor: colorScheme.surface,
|
|
|
|
backgroundColor: colorScheme.surface,
|
|
|
|
child: widget.navigationRail,
|
|
|
|
child: widget.navigationRail,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
railAnimation.isDismissed
|
|
|
|
|
|
|
|
? const SizedBox()
|
|
|
|
|
|
|
|
: const VerticalDivider(width: 1),
|
|
|
|
|
|
|
|
widget.body,
|
|
|
|
widget.body,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|