mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Flutter 3.29 beta (#2571)
This commit is contained in:
@@ -6,15 +6,16 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class ColorBox extends StatefulWidget {
|
||||
const ColorBox(
|
||||
{super.key,
|
||||
required this.label,
|
||||
required this.tone,
|
||||
required this.color,
|
||||
required this.onColor,
|
||||
required this.height,
|
||||
required this.width,
|
||||
this.displayPaletteInfo = false});
|
||||
const ColorBox({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.tone,
|
||||
required this.color,
|
||||
required this.onColor,
|
||||
required this.height,
|
||||
required this.width,
|
||||
this.displayPaletteInfo = false,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final String tone;
|
||||
@@ -47,11 +48,7 @@ class _ColorBoxState extends State<ColorBox> {
|
||||
style: fonts.labelSmall!.copyWith(color: widget.onColor),
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
top: 10,
|
||||
left: 10,
|
||||
child: Text(widget.label),
|
||||
),
|
||||
Positioned(top: 10, left: 10, child: Text(widget.label)),
|
||||
Positioned(
|
||||
bottom: 10,
|
||||
right: 10,
|
||||
@@ -81,9 +78,7 @@ class _ColorBoxState extends State<ColorBox> {
|
||||
await Clipboard.setData(data);
|
||||
messenger.hideCurrentSnackBar();
|
||||
messenger.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Copied $hex to clipboard'),
|
||||
),
|
||||
SnackBar(content: Text('Copied $hex to clipboard')),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -42,26 +42,26 @@ class ColorPalettesScreen extends StatelessWidget {
|
||||
Widget schemeView(ThemeData theme) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||
child: ColorSchemeView(
|
||||
colorScheme: theme.colorScheme,
|
||||
),
|
||||
child: ColorSchemeView(colorScheme: theme.colorScheme),
|
||||
);
|
||||
}
|
||||
|
||||
Widget dynamicColorNotice() => RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
children: [
|
||||
const TextSpan(
|
||||
text: 'To create color schemes based on a '
|
||||
'platform\'s implementation of dynamic color, '
|
||||
'use the ',
|
||||
),
|
||||
TextSpan(
|
||||
text: 'dynamic_color',
|
||||
style: const TextStyle(decoration: TextDecoration.underline),
|
||||
recognizer: TapGestureRecognizer()
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
children: [
|
||||
const TextSpan(
|
||||
text:
|
||||
'To create color schemes based on a '
|
||||
'platform\'s implementation of dynamic color, '
|
||||
'use the ',
|
||||
),
|
||||
TextSpan(
|
||||
text: 'dynamic_color',
|
||||
style: const TextStyle(decoration: TextDecoration.underline),
|
||||
recognizer:
|
||||
TapGestureRecognizer()
|
||||
..onTap = () async {
|
||||
final url = Uri.parse(
|
||||
'https://pub.dev/packages/dynamic_color',
|
||||
@@ -70,11 +70,11 @@ class ColorPalettesScreen extends StatelessWidget {
|
||||
throw Exception('Could not launch $url');
|
||||
}
|
||||
},
|
||||
),
|
||||
const TextSpan(text: ' package.'),
|
||||
],
|
||||
),
|
||||
);
|
||||
const TextSpan(text: ' package.'),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
return Expanded(
|
||||
child: LayoutBuilder(
|
||||
@@ -97,9 +97,13 @@ class ColorPalettesScreen extends StatelessWidget {
|
||||
} else {
|
||||
Color seed = Theme.of(context).colorScheme.primary;
|
||||
ColorScheme lightScheme = ColorScheme.fromSeed(
|
||||
seedColor: seed, brightness: Brightness.light);
|
||||
seedColor: seed,
|
||||
brightness: Brightness.light,
|
||||
);
|
||||
ColorScheme darkScheme = ColorScheme.fromSeed(
|
||||
seedColor: seed, brightness: Brightness.dark);
|
||||
seedColor: seed,
|
||||
brightness: Brightness.dark,
|
||||
);
|
||||
return SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
@@ -415,9 +419,7 @@ class ColorGroup extends StatelessWidget {
|
||||
return RepaintBoundary(
|
||||
child: Card(
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: Column(
|
||||
children: children,
|
||||
),
|
||||
child: Column(children: children),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -438,7 +440,7 @@ class ColorChip extends StatelessWidget {
|
||||
static Color contrastColor(Color color) =>
|
||||
switch (ThemeData.estimateBrightnessForColor(color)) {
|
||||
Brightness.dark => Colors.white,
|
||||
Brightness.light => Colors.black
|
||||
Brightness.light => Colors.black,
|
||||
};
|
||||
|
||||
@override
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,10 +15,7 @@ const double transitionLength = 500;
|
||||
|
||||
// Whether the user has chosen a theme color via a direct [ColorSeed] selection,
|
||||
// or an image [ColorImageProvider].
|
||||
enum ColorSelectionMethod {
|
||||
colorSeed,
|
||||
image,
|
||||
}
|
||||
enum ColorSelectionMethod { colorSeed, image }
|
||||
|
||||
enum ColorSeed {
|
||||
baseColor('M3 Baseline', Color(0xff6750a4)),
|
||||
@@ -37,18 +34,30 @@ enum ColorSeed {
|
||||
}
|
||||
|
||||
enum ColorImageProvider {
|
||||
leaves('Leaves',
|
||||
'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_1.png'),
|
||||
peonies('Peonies',
|
||||
'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_2.png'),
|
||||
bubbles('Bubbles',
|
||||
'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_3.png'),
|
||||
seaweed('Seaweed',
|
||||
'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_4.png'),
|
||||
seagrapes('Sea Grapes',
|
||||
'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_5.png'),
|
||||
petals('Petals',
|
||||
'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_6.png');
|
||||
leaves(
|
||||
'Leaves',
|
||||
'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_1.png',
|
||||
),
|
||||
peonies(
|
||||
'Peonies',
|
||||
'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_2.png',
|
||||
),
|
||||
bubbles(
|
||||
'Bubbles',
|
||||
'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_3.png',
|
||||
),
|
||||
seaweed(
|
||||
'Seaweed',
|
||||
'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_4.png',
|
||||
),
|
||||
seagrapes(
|
||||
'Sea Grapes',
|
||||
'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_5.png',
|
||||
),
|
||||
petals(
|
||||
'Petals',
|
||||
'https://flutter.github.io/assets-for-api-docs/assets/material/content_based_color_scheme_6.png',
|
||||
);
|
||||
|
||||
const ColorImageProvider(this.label, this.url);
|
||||
final String label;
|
||||
|
||||
@@ -71,7 +71,9 @@ class ElevationGrid extends StatelessWidget {
|
||||
final Color? surfaceTintColor;
|
||||
|
||||
List<ElevationCard> elevationCards(
|
||||
Color? shadowColor, Color? surfaceTintColor) {
|
||||
Color? shadowColor,
|
||||
Color? surfaceTintColor,
|
||||
) {
|
||||
return elevations
|
||||
.map(
|
||||
(elevationInfo) => ElevationCard(
|
||||
@@ -87,26 +89,32 @@ class ElevationGrid extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return SliverPadding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
sliver: SliverLayoutBuilder(builder: (context, constraints) {
|
||||
if (constraints.crossAxisExtent < narrowScreenWidthThreshold) {
|
||||
return SliverGrid.count(
|
||||
crossAxisCount: 3,
|
||||
children: elevationCards(shadowColor, surfaceTintColor),
|
||||
);
|
||||
} else {
|
||||
return SliverGrid.count(
|
||||
crossAxisCount: 6,
|
||||
children: elevationCards(shadowColor, surfaceTintColor),
|
||||
);
|
||||
}
|
||||
}),
|
||||
sliver: SliverLayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
if (constraints.crossAxisExtent < narrowScreenWidthThreshold) {
|
||||
return SliverGrid.count(
|
||||
crossAxisCount: 3,
|
||||
children: elevationCards(shadowColor, surfaceTintColor),
|
||||
);
|
||||
} else {
|
||||
return SliverGrid.count(
|
||||
crossAxisCount: 6,
|
||||
children: elevationCards(shadowColor, surfaceTintColor),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ElevationCard extends StatefulWidget {
|
||||
const ElevationCard(
|
||||
{super.key, required this.info, this.shadowColor, this.surfaceTint});
|
||||
const ElevationCard({
|
||||
super.key,
|
||||
required this.info,
|
||||
this.shadowColor,
|
||||
this.surfaceTint,
|
||||
});
|
||||
|
||||
final ElevationInfo info;
|
||||
final Color? shadowColor;
|
||||
|
||||
@@ -110,84 +110,85 @@ class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
|
||||
Widget createScreenFor(
|
||||
ScreenSelected screenSelected,
|
||||
bool showNavBarExample,
|
||||
) =>
|
||||
switch (screenSelected) {
|
||||
ScreenSelected.component => Expanded(
|
||||
child: OneTwoTransition(
|
||||
animation: railAnimation,
|
||||
one: FirstComponentList(
|
||||
showNavBottomBar: showNavBarExample,
|
||||
scaffoldKey: scaffoldKey,
|
||||
showSecondList: showMediumSizeLayout || showLargeSizeLayout),
|
||||
two: SecondComponentList(
|
||||
scaffoldKey: scaffoldKey,
|
||||
),
|
||||
),
|
||||
),
|
||||
ScreenSelected.color => const ColorPalettesScreen(),
|
||||
ScreenSelected.typography => const TypographyScreen(),
|
||||
ScreenSelected.elevation => const ElevationScreen()
|
||||
};
|
||||
) => switch (screenSelected) {
|
||||
ScreenSelected.component => Expanded(
|
||||
child: OneTwoTransition(
|
||||
animation: railAnimation,
|
||||
one: FirstComponentList(
|
||||
showNavBottomBar: showNavBarExample,
|
||||
scaffoldKey: scaffoldKey,
|
||||
showSecondList: showMediumSizeLayout || showLargeSizeLayout,
|
||||
),
|
||||
two: SecondComponentList(scaffoldKey: scaffoldKey),
|
||||
),
|
||||
),
|
||||
ScreenSelected.color => const ColorPalettesScreen(),
|
||||
ScreenSelected.typography => const TypographyScreen(),
|
||||
ScreenSelected.elevation => const ElevationScreen(),
|
||||
};
|
||||
|
||||
PreferredSizeWidget createAppBar() {
|
||||
return AppBar(
|
||||
title: widget.useMaterial3
|
||||
? const Text('Material 3')
|
||||
: const Text('Material 2'),
|
||||
actions: !showMediumSizeLayout && !showLargeSizeLayout
|
||||
? [
|
||||
_BrightnessButton(
|
||||
handleBrightnessChange: widget.handleBrightnessChange,
|
||||
),
|
||||
_Material3Button(
|
||||
handleMaterialVersionChange: widget.handleMaterialVersionChange,
|
||||
),
|
||||
_ColorSeedButton(
|
||||
handleColorSelect: widget.handleColorSelect,
|
||||
colorSelected: widget.colorSelected,
|
||||
colorSelectionMethod: widget.colorSelectionMethod,
|
||||
),
|
||||
_ColorImageButton(
|
||||
handleImageSelect: widget.handleImageSelect,
|
||||
imageSelected: widget.imageSelected,
|
||||
colorSelectionMethod: widget.colorSelectionMethod,
|
||||
)
|
||||
]
|
||||
: [Container()],
|
||||
title:
|
||||
widget.useMaterial3
|
||||
? const Text('Material 3')
|
||||
: const Text('Material 2'),
|
||||
actions:
|
||||
!showMediumSizeLayout && !showLargeSizeLayout
|
||||
? [
|
||||
_BrightnessButton(
|
||||
handleBrightnessChange: widget.handleBrightnessChange,
|
||||
),
|
||||
_Material3Button(
|
||||
handleMaterialVersionChange:
|
||||
widget.handleMaterialVersionChange,
|
||||
),
|
||||
_ColorSeedButton(
|
||||
handleColorSelect: widget.handleColorSelect,
|
||||
colorSelected: widget.colorSelected,
|
||||
colorSelectionMethod: widget.colorSelectionMethod,
|
||||
),
|
||||
_ColorImageButton(
|
||||
handleImageSelect: widget.handleImageSelect,
|
||||
imageSelected: widget.imageSelected,
|
||||
colorSelectionMethod: widget.colorSelectionMethod,
|
||||
),
|
||||
]
|
||||
: [Container()],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _trailingActions() => Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Flexible(
|
||||
child: _BrightnessButton(
|
||||
handleBrightnessChange: widget.handleBrightnessChange,
|
||||
showTooltipBelow: false,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: _Material3Button(
|
||||
handleMaterialVersionChange: widget.handleMaterialVersionChange,
|
||||
showTooltipBelow: false,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: _ColorSeedButton(
|
||||
handleColorSelect: widget.handleColorSelect,
|
||||
colorSelected: widget.colorSelected,
|
||||
colorSelectionMethod: widget.colorSelectionMethod,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: _ColorImageButton(
|
||||
handleImageSelect: widget.handleImageSelect,
|
||||
imageSelected: widget.imageSelected,
|
||||
colorSelectionMethod: widget.colorSelectionMethod,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Flexible(
|
||||
child: _BrightnessButton(
|
||||
handleBrightnessChange: widget.handleBrightnessChange,
|
||||
showTooltipBelow: false,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: _Material3Button(
|
||||
handleMaterialVersionChange: widget.handleMaterialVersionChange,
|
||||
showTooltipBelow: false,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: _ColorSeedButton(
|
||||
handleColorSelect: widget.handleColorSelect,
|
||||
colorSelected: widget.colorSelected,
|
||||
colorSelectionMethod: widget.colorSelectionMethod,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: _ColorImageButton(
|
||||
handleImageSelect: widget.handleImageSelect,
|
||||
imageSelected: widget.imageSelected,
|
||||
colorSelectionMethod: widget.colorSelectionMethod,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -200,7 +201,9 @@ class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
|
||||
railAnimation: railAnimation,
|
||||
appBar: createAppBar(),
|
||||
body: createScreenFor(
|
||||
ScreenSelected.values[screenIndex], controller.value == 1),
|
||||
ScreenSelected.values[screenIndex],
|
||||
controller.value == 1,
|
||||
),
|
||||
navigationRail: NavigationRail(
|
||||
extended: showLargeSizeLayout,
|
||||
destinations: navRailDestinations,
|
||||
@@ -214,20 +217,21 @@ class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
|
||||
trailing: Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 20),
|
||||
child: showLargeSizeLayout
|
||||
? _ExpandedTrailingActions(
|
||||
useLightMode: widget.useLightMode,
|
||||
handleBrightnessChange: widget.handleBrightnessChange,
|
||||
useMaterial3: widget.useMaterial3,
|
||||
handleMaterialVersionChange:
|
||||
widget.handleMaterialVersionChange,
|
||||
handleImageSelect: widget.handleImageSelect,
|
||||
handleColorSelect: widget.handleColorSelect,
|
||||
colorSelectionMethod: widget.colorSelectionMethod,
|
||||
imageSelected: widget.imageSelected,
|
||||
colorSelected: widget.colorSelected,
|
||||
)
|
||||
: _trailingActions(),
|
||||
child:
|
||||
showLargeSizeLayout
|
||||
? _ExpandedTrailingActions(
|
||||
useLightMode: widget.useLightMode,
|
||||
handleBrightnessChange: widget.handleBrightnessChange,
|
||||
useMaterial3: widget.useMaterial3,
|
||||
handleMaterialVersionChange:
|
||||
widget.handleMaterialVersionChange,
|
||||
handleImageSelect: widget.handleImageSelect,
|
||||
handleColorSelect: widget.handleColorSelect,
|
||||
colorSelectionMethod: widget.colorSelectionMethod,
|
||||
imageSelected: widget.imageSelected,
|
||||
colorSelected: widget.colorSelected,
|
||||
)
|
||||
: _trailingActions(),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -263,9 +267,10 @@ class _BrightnessButton extends StatelessWidget {
|
||||
preferBelow: showTooltipBelow,
|
||||
message: 'Toggle brightness',
|
||||
child: IconButton(
|
||||
icon: isBright
|
||||
? const Icon(Icons.dark_mode_outlined)
|
||||
: const Icon(Icons.light_mode_outlined),
|
||||
icon:
|
||||
isBright
|
||||
? const Icon(Icons.dark_mode_outlined)
|
||||
: const Icon(Icons.light_mode_outlined),
|
||||
onPressed: () => handleBrightnessChange(!isBright),
|
||||
),
|
||||
);
|
||||
@@ -288,9 +293,10 @@ class _Material3Button extends StatelessWidget {
|
||||
preferBelow: showTooltipBelow,
|
||||
message: 'Switch to Material ${useMaterial3 ? 2 : 3}',
|
||||
child: IconButton(
|
||||
icon: useMaterial3
|
||||
? const Icon(Icons.filter_2)
|
||||
: const Icon(Icons.filter_3),
|
||||
icon:
|
||||
useMaterial3
|
||||
? const Icon(Icons.filter_2)
|
||||
: const Icon(Icons.filter_3),
|
||||
onPressed: handleMaterialVersionChange,
|
||||
),
|
||||
);
|
||||
@@ -311,9 +317,7 @@ class _ColorSeedButton extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopupMenuButton(
|
||||
icon: const Icon(
|
||||
Icons.palette_outlined,
|
||||
),
|
||||
icon: const Icon(Icons.palette_outlined),
|
||||
tooltip: 'Select a seed color',
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
itemBuilder: (context) {
|
||||
@@ -322,7 +326,8 @@ class _ColorSeedButton extends StatelessWidget {
|
||||
|
||||
return PopupMenuItem(
|
||||
value: index,
|
||||
enabled: currentColor != colorSelected ||
|
||||
enabled:
|
||||
currentColor != colorSelected ||
|
||||
colorSelectionMethod != ColorSelectionMethod.colorSeed,
|
||||
child: Wrap(
|
||||
children: [
|
||||
@@ -364,9 +369,7 @@ class _ColorImageButton extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopupMenuButton(
|
||||
icon: const Icon(
|
||||
Icons.image_outlined,
|
||||
),
|
||||
icon: const Icon(Icons.image_outlined),
|
||||
tooltip: 'Select a color extraction image',
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
itemBuilder: (context) {
|
||||
@@ -375,7 +378,8 @@ class _ColorImageButton extends StatelessWidget {
|
||||
|
||||
return PopupMenuItem(
|
||||
value: index,
|
||||
enabled: currentImageProvider != imageSelected ||
|
||||
enabled:
|
||||
currentImageProvider != imageSelected ||
|
||||
colorSelectionMethod != ColorSelectionMethod.image,
|
||||
child: Wrap(
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
@@ -449,10 +453,11 @@ class _ExpandedTrailingActions extends StatelessWidget {
|
||||
const Text('Brightness'),
|
||||
Expanded(child: Container()),
|
||||
Switch(
|
||||
value: useLightMode,
|
||||
onChanged: (value) {
|
||||
handleBrightnessChange(value);
|
||||
})
|
||||
value: useLightMode,
|
||||
onChanged: (value) {
|
||||
handleBrightnessChange(value);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
@@ -462,10 +467,11 @@ class _ExpandedTrailingActions extends StatelessWidget {
|
||||
: const Text('Material 2'),
|
||||
Expanded(child: Container()),
|
||||
Switch(
|
||||
value: useMaterial3,
|
||||
onChanged: (_) {
|
||||
handleMaterialVersionChange();
|
||||
})
|
||||
value: useMaterial3,
|
||||
onChanged: (_) {
|
||||
handleMaterialVersionChange();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const Divider(),
|
||||
@@ -511,7 +517,8 @@ class _ExpandedColorSeedAction extends StatelessWidget {
|
||||
(i) => IconButton(
|
||||
icon: const Icon(Icons.radio_button_unchecked),
|
||||
color: ColorSeed.values[i].color,
|
||||
isSelected: colorSelected.color == ColorSeed.values[i].color &&
|
||||
isSelected:
|
||||
colorSelected.color == ColorSeed.values[i].color &&
|
||||
colorSelectionMethod == ColorSelectionMethod.colorSeed,
|
||||
selectedIcon: const Icon(Icons.circle),
|
||||
onPressed: () {
|
||||
@@ -555,10 +562,12 @@ class _ExpandedImageColorAction extends StatelessWidget {
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Material(
|
||||
borderRadius: BorderRadius.circular(4.0),
|
||||
elevation: imageSelected == ColorImageProvider.values[i] &&
|
||||
colorSelectionMethod == ColorSelectionMethod.image
|
||||
? 3
|
||||
: 0,
|
||||
elevation:
|
||||
imageSelected == ColorImageProvider.values[i] &&
|
||||
colorSelectionMethod ==
|
||||
ColorSelectionMethod.image
|
||||
? 3
|
||||
: 0,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: ClipRRect(
|
||||
@@ -580,15 +589,16 @@ class _ExpandedImageColorAction extends StatelessWidget {
|
||||
}
|
||||
|
||||
class NavigationTransition extends StatefulWidget {
|
||||
const NavigationTransition(
|
||||
{super.key,
|
||||
required this.scaffoldKey,
|
||||
required this.animationController,
|
||||
required this.railAnimation,
|
||||
required this.navigationRail,
|
||||
required this.navigationBar,
|
||||
required this.appBar,
|
||||
required this.body});
|
||||
const NavigationTransition({
|
||||
super.key,
|
||||
required this.scaffoldKey,
|
||||
required this.animationController,
|
||||
required this.railAnimation,
|
||||
required this.navigationRail,
|
||||
required this.navigationBar,
|
||||
required this.appBar,
|
||||
required this.body,
|
||||
});
|
||||
|
||||
final GlobalKey<ScaffoldState> scaffoldKey;
|
||||
final AnimationController animationController;
|
||||
@@ -617,10 +627,7 @@ class _NavigationTransitionState extends State<NavigationTransition> {
|
||||
railAnimation = widget.railAnimation;
|
||||
|
||||
barAnimation = ReverseAnimation(
|
||||
CurvedAnimation(
|
||||
parent: controller,
|
||||
curve: const Interval(0.0, 0.5),
|
||||
),
|
||||
CurvedAnimation(parent: controller, curve: const Interval(0.0, 0.5)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -651,62 +658,53 @@ class _NavigationTransitionState extends State<NavigationTransition> {
|
||||
}
|
||||
}
|
||||
|
||||
final List<NavigationRailDestination> navRailDestinations = appBarDestinations
|
||||
.map(
|
||||
(destination) => NavigationRailDestination(
|
||||
icon: Tooltip(
|
||||
message: destination.label,
|
||||
child: destination.icon,
|
||||
),
|
||||
selectedIcon: Tooltip(
|
||||
message: destination.label,
|
||||
child: destination.selectedIcon,
|
||||
),
|
||||
label: Text(destination.label),
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
final List<NavigationRailDestination> navRailDestinations =
|
||||
appBarDestinations
|
||||
.map(
|
||||
(destination) => NavigationRailDestination(
|
||||
icon: Tooltip(message: destination.label, child: destination.icon),
|
||||
selectedIcon: Tooltip(
|
||||
message: destination.label,
|
||||
child: destination.selectedIcon,
|
||||
),
|
||||
label: Text(destination.label),
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
|
||||
class SizeAnimation extends CurvedAnimation {
|
||||
SizeAnimation(Animation<double> parent)
|
||||
: super(
|
||||
parent: parent,
|
||||
curve: const Interval(
|
||||
0.2,
|
||||
0.8,
|
||||
curve: Curves.easeInOutCubicEmphasized,
|
||||
),
|
||||
reverseCurve: Interval(
|
||||
0,
|
||||
0.2,
|
||||
curve: Curves.easeInOutCubicEmphasized.flipped,
|
||||
),
|
||||
);
|
||||
: super(
|
||||
parent: parent,
|
||||
curve: const Interval(0.2, 0.8, curve: Curves.easeInOutCubicEmphasized),
|
||||
reverseCurve: Interval(
|
||||
0,
|
||||
0.2,
|
||||
curve: Curves.easeInOutCubicEmphasized.flipped,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class OffsetAnimation extends CurvedAnimation {
|
||||
OffsetAnimation(Animation<double> parent)
|
||||
: super(
|
||||
parent: parent,
|
||||
curve: const Interval(
|
||||
0.4,
|
||||
1.0,
|
||||
curve: Curves.easeInOutCubicEmphasized,
|
||||
),
|
||||
reverseCurve: Interval(
|
||||
0,
|
||||
0.2,
|
||||
curve: Curves.easeInOutCubicEmphasized.flipped,
|
||||
),
|
||||
);
|
||||
: super(
|
||||
parent: parent,
|
||||
curve: const Interval(0.4, 1.0, curve: Curves.easeInOutCubicEmphasized),
|
||||
reverseCurve: Interval(
|
||||
0,
|
||||
0.2,
|
||||
curve: Curves.easeInOutCubicEmphasized.flipped,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class RailTransition extends StatefulWidget {
|
||||
const RailTransition(
|
||||
{super.key,
|
||||
required this.animation,
|
||||
required this.backgroundColor,
|
||||
required this.child});
|
||||
const RailTransition({
|
||||
super.key,
|
||||
required this.animation,
|
||||
required this.backgroundColor,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
final Animation<double> animation;
|
||||
final Widget child;
|
||||
@@ -758,11 +756,12 @@ class _RailTransition extends State<RailTransition> {
|
||||
}
|
||||
|
||||
class BarTransition extends StatefulWidget {
|
||||
const BarTransition(
|
||||
{super.key,
|
||||
required this.animation,
|
||||
required this.backgroundColor,
|
||||
required this.child});
|
||||
const BarTransition({
|
||||
super.key,
|
||||
required this.animation,
|
||||
required this.backgroundColor,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
final Animation<double> animation;
|
||||
final Color backgroundColor;
|
||||
@@ -848,10 +847,7 @@ class _OneTwoTransitionState extends State<OneTwoTransition> {
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
flex: mediumWidthBreakpoint.toInt(),
|
||||
child: widget.one,
|
||||
),
|
||||
Flexible(flex: mediumWidthBreakpoint.toInt(), child: widget.one),
|
||||
if (widthAnimation.value.toInt() > 0) ...[
|
||||
Flexible(
|
||||
flex: widthAnimation.value.toInt(),
|
||||
@@ -859,7 +855,7 @@ class _OneTwoTransitionState extends State<OneTwoTransition> {
|
||||
translation: offsetAnimation.value,
|
||||
child: widget.two,
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
@@ -27,12 +27,12 @@ class _AppState extends State<App> {
|
||||
ColorSelectionMethod colorSelectionMethod = ColorSelectionMethod.colorSeed;
|
||||
|
||||
bool get useLightMode => switch (themeMode) {
|
||||
ThemeMode.system =>
|
||||
View.of(context).platformDispatcher.platformBrightness ==
|
||||
Brightness.light,
|
||||
ThemeMode.light => true,
|
||||
ThemeMode.dark => false
|
||||
};
|
||||
ThemeMode.system =>
|
||||
View.of(context).platformDispatcher.platformBrightness ==
|
||||
Brightness.light,
|
||||
ThemeMode.light => true,
|
||||
ThemeMode.dark => false,
|
||||
};
|
||||
|
||||
void handleBrightnessChange(bool useLightMode) {
|
||||
setState(() {
|
||||
@@ -55,8 +55,9 @@ class _AppState extends State<App> {
|
||||
|
||||
void handleImageSelect(int value) {
|
||||
final String url = ColorImageProvider.values[value].url;
|
||||
ColorScheme.fromImageProvider(provider: NetworkImage(url))
|
||||
.then((newScheme) {
|
||||
ColorScheme.fromImageProvider(provider: NetworkImage(url)).then((
|
||||
newScheme,
|
||||
) {
|
||||
setState(() {
|
||||
colorSelectionMethod = ColorSelectionMethod.image;
|
||||
imageSelected = ColorImageProvider.values[value];
|
||||
@@ -72,19 +73,22 @@ class _AppState extends State<App> {
|
||||
title: 'Material 3',
|
||||
themeMode: themeMode,
|
||||
theme: ThemeData(
|
||||
colorSchemeSeed: colorSelectionMethod == ColorSelectionMethod.colorSeed
|
||||
? colorSelected.color
|
||||
: null,
|
||||
colorScheme: colorSelectionMethod == ColorSelectionMethod.image
|
||||
? imageColorScheme
|
||||
: null,
|
||||
colorSchemeSeed:
|
||||
colorSelectionMethod == ColorSelectionMethod.colorSeed
|
||||
? colorSelected.color
|
||||
: null,
|
||||
colorScheme:
|
||||
colorSelectionMethod == ColorSelectionMethod.image
|
||||
? imageColorScheme
|
||||
: null,
|
||||
useMaterial3: useMaterial3,
|
||||
brightness: Brightness.light,
|
||||
),
|
||||
darkTheme: ThemeData(
|
||||
colorSchemeSeed: colorSelectionMethod == ColorSelectionMethod.colorSeed
|
||||
? colorSelected.color
|
||||
: imageColorScheme!.primary,
|
||||
colorSchemeSeed:
|
||||
colorSelectionMethod == ColorSelectionMethod.colorSeed
|
||||
? colorSelected.color
|
||||
: imageColorScheme!.primary,
|
||||
useMaterial3: useMaterial3,
|
||||
brightness: Brightness.dark,
|
||||
),
|
||||
|
||||
@@ -46,16 +46,13 @@ class _SchemePreviewState extends State<SchemePreview> {
|
||||
color: scheme.surface,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: theme.brightness == widget.brightness
|
||||
? colors.outlineVariant
|
||||
: Colors.transparent,
|
||||
color:
|
||||
theme.brightness == widget.brightness
|
||||
? colors.outlineVariant
|
||||
: Colors.transparent,
|
||||
),
|
||||
),
|
||||
padding: const EdgeInsets.only(
|
||||
top: 16,
|
||||
left: 16,
|
||||
right: 16,
|
||||
),
|
||||
padding: const EdgeInsets.only(top: 16, left: 16, right: 16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
||||
@@ -9,25 +9,37 @@ class TypographyScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final textTheme = Theme.of(context)
|
||||
.textTheme
|
||||
.apply(displayColor: Theme.of(context).colorScheme.onSurface);
|
||||
final textTheme = Theme.of(
|
||||
context,
|
||||
).textTheme.apply(displayColor: Theme.of(context).colorScheme.onSurface);
|
||||
return Expanded(
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
const SizedBox(height: 8),
|
||||
TextStyleExample(
|
||||
name: 'Display Large', style: textTheme.displayLarge!),
|
||||
name: 'Display Large',
|
||||
style: textTheme.displayLarge!,
|
||||
),
|
||||
TextStyleExample(
|
||||
name: 'Display Medium', style: textTheme.displayMedium!),
|
||||
name: 'Display Medium',
|
||||
style: textTheme.displayMedium!,
|
||||
),
|
||||
TextStyleExample(
|
||||
name: 'Display Small', style: textTheme.displaySmall!),
|
||||
name: 'Display Small',
|
||||
style: textTheme.displaySmall!,
|
||||
),
|
||||
TextStyleExample(
|
||||
name: 'Headline Large', style: textTheme.headlineLarge!),
|
||||
name: 'Headline Large',
|
||||
style: textTheme.headlineLarge!,
|
||||
),
|
||||
TextStyleExample(
|
||||
name: 'Headline Medium', style: textTheme.headlineMedium!),
|
||||
name: 'Headline Medium',
|
||||
style: textTheme.headlineMedium!,
|
||||
),
|
||||
TextStyleExample(
|
||||
name: 'Headline Small', style: textTheme.headlineSmall!),
|
||||
name: 'Headline Small',
|
||||
style: textTheme.headlineSmall!,
|
||||
),
|
||||
TextStyleExample(name: 'Title Large', style: textTheme.titleLarge!),
|
||||
TextStyleExample(name: 'Title Medium', style: textTheme.titleMedium!),
|
||||
TextStyleExample(name: 'Title Small', style: textTheme.titleSmall!),
|
||||
@@ -44,11 +56,7 @@ class TypographyScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
class TextStyleExample extends StatelessWidget {
|
||||
const TextStyleExample({
|
||||
super.key,
|
||||
required this.name,
|
||||
required this.style,
|
||||
});
|
||||
const TextStyleExample({super.key, required this.name, required this.style});
|
||||
|
||||
final String name;
|
||||
final TextStyle style;
|
||||
|
||||
Reference in New Issue
Block a user