siyao
4 年前
当前提交
57cac2f3
共有 228 个文件被更改,包括 310 次插入 和 4538 次删除
-
17Samples/UIWidgetsSamples_2019_4/Assets/TextTest.cs
-
4com.unity.uiwidgets/Runtime/animation/animation_controller.cs
-
4com.unity.uiwidgets/Runtime/async2/future.cs
-
1com.unity.uiwidgets/Runtime/foundation/binding.cs
-
1com.unity.uiwidgets/Runtime/foundation/debug.cs
-
70com.unity.uiwidgets/Runtime/material/colors.cs
-
20com.unity.uiwidgets/Runtime/painting/image_provider.cs
-
2com.unity.uiwidgets/Runtime/painting/image_resolution.cs
-
4com.unity.uiwidgets/Runtime/painting/image_stream.cs
-
7com.unity.uiwidgets/Runtime/rendering/viewport_offset.cs
-
12com.unity.uiwidgets/Runtime/service/clipboard.cs
-
4com.unity.uiwidgets/Runtime/ui/painting/codec.cs
-
1com.unity.uiwidgets/Runtime/widgets/animated_switcher.cs
-
19com.unity.uiwidgets/Runtime/widgets/app.cs
-
34com.unity.uiwidgets/Runtime/widgets/binding.cs
-
12com.unity.uiwidgets/Runtime/widgets/dismissible.cs
-
9com.unity.uiwidgets/Runtime/widgets/editable_text.cs
-
7com.unity.uiwidgets/Runtime/widgets/focus_manager.cs
-
21com.unity.uiwidgets/Runtime/widgets/image.cs
-
11com.unity.uiwidgets/Runtime/widgets/list_wheel_scroll_view.cs
-
42com.unity.uiwidgets/Runtime/widgets/localizations.cs
-
65com.unity.uiwidgets/Runtime/widgets/navigator.cs
-
10com.unity.uiwidgets/Runtime/widgets/nested_scroll_view.cs
-
8com.unity.uiwidgets/Runtime/widgets/page_view.cs
-
105com.unity.uiwidgets/Runtime/widgets/routes.cs
-
16com.unity.uiwidgets/Runtime/widgets/scroll_activity.cs
-
8com.unity.uiwidgets/Runtime/widgets/scroll_controller.cs
-
10com.unity.uiwidgets/Runtime/widgets/scroll_position.cs
-
6com.unity.uiwidgets/Runtime/widgets/scroll_position_with_single_context.cs
-
9com.unity.uiwidgets/Runtime/widgets/scrollable.cs
-
9com.unity.uiwidgets/Runtime/widgets/selectable_text.cs
-
17com.unity.uiwidgets/Runtime/widgets/texture.cs
-
10com.unity.uiwidgets/Runtime/widgets/widget_inspector.cs
-
5engine/src/lib/ui/window/window.cc
-
8Samples/UIWidgetsSamples_2019_4/Assets/Editor.meta
-
8Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample.meta
-
8Samples/UIWidgetsSamples_2019_4/Assets/RaycastableSample.meta
-
8Samples/UIWidgetsSamples_2019_4/Assets/ReduxSample.meta
-
8Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery.meta
-
8Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsSample.meta
-
8Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsTheatre.meta
-
204com.unity.uiwidgets/Runtime/material/text_selection.cs
-
11com.unity.uiwidgets/Runtime/material/text_selection.cs.meta
-
11com.unity.uiwidgets/Runtime/material/button.cs.meta
-
11com.unity.uiwidgets/Runtime/material/button_theme.cs.meta
-
352com.unity.uiwidgets/Runtime/material/color_scheme.cs
-
11com.unity.uiwidgets/Runtime/material/color_scheme.cs.meta
-
11com.unity.uiwidgets/Runtime/material/colors.cs.meta
-
26com.unity.uiwidgets/Runtime/material/constants.cs
-
11com.unity.uiwidgets/Runtime/material/constants.cs.meta
-
11com.unity.uiwidgets/Runtime/material/debug.cs.meta
-
11com.unity.uiwidgets/Runtime/material/ink_decoration.cs.meta
-
11com.unity.uiwidgets/Runtime/material/ink_highlight.cs.meta
-
11com.unity.uiwidgets/Runtime/material/ink_splash.cs.meta
-
11com.unity.uiwidgets/Runtime/material/ink_well.cs.meta
-
11com.unity.uiwidgets/Runtime/material/material.cs.meta
-
11com.unity.uiwidgets/Runtime/material/material_button.cs.meta
-
371com.unity.uiwidgets/Runtime/material/text_theme.cs
-
11com.unity.uiwidgets/Runtime/material/text_theme.cs.meta
-
147com.unity.uiwidgets/Runtime/material/theme.cs
-
11com.unity.uiwidgets/Runtime/material/theme.cs.meta
-
11com.unity.uiwidgets/Runtime/material/theme_data.cs.meta
-
449com.unity.uiwidgets/Runtime/material/typography.cs
-
11com.unity.uiwidgets/Runtime/material/typography.cs.meta
-
112com.unity.uiwidgets/Runtime/material/scrollbar.cs
-
11com.unity.uiwidgets/Runtime/material/scrollbar.cs.meta
-
425com.unity.uiwidgets/Runtime/material/arc.cs
-
11com.unity.uiwidgets/Runtime/material/arc.cs.meta
-
169com.unity.uiwidgets/Runtime/material/button.cs
-
68com.unity.uiwidgets/Runtime/material/button_bar.cs
-
11com.unity.uiwidgets/Runtime/material/button_bar.cs.meta
-
62com.unity.uiwidgets/Runtime/material/card.cs
-
11com.unity.uiwidgets/Runtime/material/card.cs.meta
-
95com.unity.uiwidgets/Runtime/material/debug.cs
-
47com.unity.uiwidgets/Runtime/material/divider.cs
-
11com.unity.uiwidgets/Runtime/material/divider.cs.meta
-
325com.unity.uiwidgets/Runtime/material/drawer.cs
-
11com.unity.uiwidgets/Runtime/material/drawer.cs.meta
-
76com.unity.uiwidgets/Runtime/material/drawer_header.cs
-
11com.unity.uiwidgets/Runtime/material/drawer_header.cs.meta
-
94com.unity.uiwidgets/Runtime/material/expand_icon.cs
-
11com.unity.uiwidgets/Runtime/material/expand_icon.cs.meta
-
343com.unity.uiwidgets/Runtime/material/expansion_panel.cs
-
11com.unity.uiwidgets/Runtime/material/expansion_panel.cs.meta
-
176com.unity.uiwidgets/Runtime/material/expansion_tile.cs
-
11com.unity.uiwidgets/Runtime/material/expansion_tile.cs.meta
-
178com.unity.uiwidgets/Runtime/material/flat_button.cs
-
11com.unity.uiwidgets/Runtime/material/flat_button.cs.meta
-
53com.unity.uiwidgets/Runtime/material/grid_tile.cs
-
11com.unity.uiwidgets/Runtime/material/grid_tile.cs.meta
-
121com.unity.uiwidgets/Runtime/material/icon_button.cs
|
|||
fileFormatVersion: 2 |
|||
guid: 0ae90c343ee0e4f7daf768fe6383340f |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 611706478d8aa410983272ad601895d3 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 4e70bfdbd732446138a5acef1423b347 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 5d9b41f3c48f94f93b5aaf521adbe0bf |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: d5570637d1b25467596ae3c19ff7f0b2 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 3663814d042c44976a72d5fb8a41cdf9 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: b54f053c2c5d34691b30237abaf17e14 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.service; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
using Canvas = Unity.UIWidgets.ui.Canvas; |
|||
using Color = Unity.UIWidgets.ui.Color; |
|||
using Rect = Unity.UIWidgets.ui.Rect; |
|||
using Transform = Unity.UIWidgets.widgets.Transform; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public static class MaterialUtils { |
|||
public static readonly TextSelectionControls materialTextSelectionControls = |
|||
new _MaterialTextSelectionControls(); |
|||
|
|||
internal const float _kHandleSize = 22.0f; |
|||
|
|||
internal const float _kToolbarScreenPadding = 8.0f; |
|||
|
|||
} |
|||
|
|||
class _TextSelectionToolbar : StatelessWidget { |
|||
public _TextSelectionToolbar(Key key = null, VoidCallback handleCut = null, |
|||
VoidCallback handleCopy = null, VoidCallback handlePaste = null, VoidCallback handleSelectAll = null) : base(key: key) { |
|||
this.handleCut = handleCut; |
|||
this.handleCopy = handleCopy; |
|||
this.handlePaste = handlePaste; |
|||
this.handleSelectAll = handleSelectAll; |
|||
} |
|||
|
|||
public readonly VoidCallback handleCut; |
|||
public readonly VoidCallback handleCopy; |
|||
public readonly VoidCallback handlePaste; |
|||
public readonly VoidCallback handleSelectAll; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
List<Widget> items = new List<Widget>(); |
|||
MaterialLocalizations localizations = MaterialLocalizations.of(context); |
|||
if (handleCut != null) { |
|||
items.Add(new FlatButton(child: new Text(localizations.cutButtonLabel), onPressed: handleCut)); |
|||
} |
|||
|
|||
if (handleCopy != null) { |
|||
items.Add(new FlatButton(child: new Text(localizations.copyButtonLabel), onPressed: handleCopy)); |
|||
} |
|||
|
|||
if (handlePaste != null) { |
|||
|
|||
items.Add(new FlatButton(child: new Text(localizations.pasteButtonLabel), onPressed: handlePaste)); |
|||
} |
|||
|
|||
if (handleSelectAll != null) { |
|||
items.Add(new FlatButton(child: new Text(localizations.selectAllButtonLabel), |
|||
onPressed: handleSelectAll)); |
|||
} |
|||
|
|||
return new Material( |
|||
elevation: 1.0f, |
|||
child: new Container( |
|||
color: new Color(0xFFEFEFEF), |
|||
height: 44.0f, child: new Row(mainAxisSize: MainAxisSize.min, children: items)) |
|||
); |
|||
} |
|||
} |
|||
|
|||
class _TextSelectionToolbarLayout : SingleChildLayoutDelegate { |
|||
internal _TextSelectionToolbarLayout(Size screenSize = null, Rect globalEditableRegion = null, |
|||
Offset position = null) { |
|||
this.screenSize = screenSize; |
|||
this.globalEditableRegion = globalEditableRegion; |
|||
this.position = position; |
|||
} |
|||
|
|||
public readonly Size screenSize; |
|||
public readonly Rect globalEditableRegion; |
|||
public readonly Offset position; |
|||
|
|||
public override BoxConstraints getConstraintsForChild(BoxConstraints constraints) { |
|||
return constraints.loosen(); |
|||
} |
|||
|
|||
public override Offset getPositionForChild(Size size, Size childSize) { |
|||
Offset globalPosition = globalEditableRegion.topLeft + position; |
|||
|
|||
float x = globalPosition.dx - childSize.width / 2.0f; |
|||
float y = globalPosition.dy - childSize.height; |
|||
|
|||
if (x < MaterialUtils._kToolbarScreenPadding) { |
|||
x = MaterialUtils._kToolbarScreenPadding; |
|||
} |
|||
else if (x + childSize.width > screenSize.width - MaterialUtils._kToolbarScreenPadding) { |
|||
x = screenSize.width - childSize.width - MaterialUtils._kToolbarScreenPadding; |
|||
} |
|||
|
|||
if (y < MaterialUtils._kToolbarScreenPadding) { |
|||
y = MaterialUtils._kToolbarScreenPadding; |
|||
} |
|||
else if (y + childSize.height > screenSize.height - MaterialUtils._kToolbarScreenPadding) { |
|||
y = screenSize.height - childSize.height - MaterialUtils._kToolbarScreenPadding; |
|||
} |
|||
|
|||
return new Offset(x, y); |
|||
} |
|||
|
|||
public override bool shouldRelayout(SingleChildLayoutDelegate oldDelegate) { |
|||
return position != ((_TextSelectionToolbarLayout) oldDelegate).position; |
|||
} |
|||
} |
|||
|
|||
class _TextSelectionHandlePainter : AbstractCustomPainter { |
|||
internal _TextSelectionHandlePainter(Color color) { |
|||
this.color = color; |
|||
} |
|||
|
|||
public readonly Color color; |
|||
|
|||
public override void paint(Canvas canvas, Size size) { |
|||
Paint paint = new Paint(); |
|||
paint.color = color; |
|||
float radius = size.width / 2.0f; |
|||
canvas.drawCircle(new Offset(radius, radius), radius, paint); |
|||
canvas.drawRect(Rect.fromLTWH(0.0f, 0.0f, radius, radius), paint); |
|||
} |
|||
|
|||
|
|||
public override bool shouldRepaint(CustomPainter oldPainter) { |
|||
return color != ((_TextSelectionHandlePainter) oldPainter).color; |
|||
} |
|||
} |
|||
|
|||
class _MaterialTextSelectionControls : TextSelectionControls { |
|||
public override Size handleSize { |
|||
get { |
|||
return new Size(MaterialUtils._kHandleSize, |
|||
MaterialUtils._kHandleSize); |
|||
} |
|||
} |
|||
|
|||
public override Widget buildToolbar(BuildContext context, Rect globalEditableRegion, Offset position, |
|||
TextSelectionDelegate selectionDelegate) { |
|||
return new ConstrainedBox( |
|||
constraints: BoxConstraints.tight(globalEditableRegion.size), |
|||
child: new CustomSingleChildLayout( |
|||
layoutDelegate: new _TextSelectionToolbarLayout( |
|||
MediaQuery.of(context).size, |
|||
globalEditableRegion, |
|||
position |
|||
), |
|||
child: new _TextSelectionToolbar( |
|||
handleCut: canCut(selectionDelegate) |
|||
? () => handleCut(selectionDelegate) |
|||
: (VoidCallback) null, |
|||
handleCopy: canCopy(selectionDelegate) |
|||
? () => handleCopy(selectionDelegate) |
|||
: (VoidCallback) null, |
|||
handlePaste: canPaste(selectionDelegate) |
|||
? () => handlePaste(selectionDelegate) |
|||
: (VoidCallback) null, |
|||
handleSelectAll: canSelectAll(selectionDelegate) |
|||
? () => handleSelectAll(selectionDelegate) |
|||
: (VoidCallback) null |
|||
) |
|||
) |
|||
); |
|||
} |
|||
|
|||
public override Widget buildHandle(BuildContext context, TextSelectionHandleType type, float textLineHeight) { |
|||
Widget handle = new Padding( |
|||
padding: EdgeInsets.only(right: 26.0f, bottom: 26.0f), |
|||
child: new SizedBox( |
|||
width: MaterialUtils._kHandleSize, |
|||
height: MaterialUtils._kHandleSize, |
|||
child: new CustomPaint( |
|||
painter: new _TextSelectionHandlePainter( |
|||
color: Theme.of(context).textSelectionHandleColor |
|||
) |
|||
) |
|||
) |
|||
); |
|||
|
|||
switch (type) { |
|||
case TextSelectionHandleType.left: // points up-right
|
|||
return new Transform( |
|||
transform: new Matrix4().rotationZ(Mathf.PI / 2), |
|||
child: handle |
|||
); |
|||
case TextSelectionHandleType.right: // points up-left
|
|||
return handle; |
|||
case TextSelectionHandleType.collapsed: // points up
|
|||
return new Transform( |
|||
transform: new Matrix4().rotationZ(Mathf.PI / 4), |
|||
child: handle |
|||
); |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 33685d6edaab14322aa1b854fdd7c3e6 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 5452e0dd1a19646fda9cc8dc0b388ee4 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: c00e9535ad31f481cbe2b83d490d714d |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.service; |
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class ColorScheme : Diagnosticable, IEquatable<ColorScheme> { |
|||
public ColorScheme( |
|||
Color primary, |
|||
Color primaryVariant, |
|||
Color secondary, |
|||
Color secondaryVariant, |
|||
Color surface, |
|||
Color background, |
|||
Color error, |
|||
Color onPrimary, |
|||
Color onSecondary, |
|||
Color onSurface, |
|||
Color onBackground, |
|||
Color onError, |
|||
Brightness brightness) { |
|||
D.assert(primary != null); |
|||
D.assert(primaryVariant != null); |
|||
D.assert(secondary != null); |
|||
D.assert(secondaryVariant != null); |
|||
D.assert(surface != null); |
|||
D.assert(background != null); |
|||
D.assert(error != null); |
|||
D.assert(onPrimary != null); |
|||
D.assert(onSecondary != null); |
|||
D.assert(onSurface != null); |
|||
D.assert(onBackground != null); |
|||
D.assert(onError != null); |
|||
|
|||
this.primary = primary; |
|||
this.primaryVariant = primaryVariant; |
|||
this.secondary = secondary; |
|||
this.secondaryVariant = secondaryVariant; |
|||
this.surface = surface; |
|||
this.background = background; |
|||
this.error = error; |
|||
this.onPrimary = onPrimary; |
|||
this.onSecondary = onSecondary; |
|||
this.onSurface = onSurface; |
|||
this.onBackground = onBackground; |
|||
this.onError = onError; |
|||
this.brightness = brightness; |
|||
} |
|||
|
|||
public static ColorScheme light( |
|||
Color primary = null, |
|||
Color primaryVariant = null, |
|||
Color secondary = null, |
|||
Color secondaryVariant = null, |
|||
Color surface = null, |
|||
Color background = null, |
|||
Color error = null, |
|||
Color onPrimary = null, |
|||
Color onSecondary = null, |
|||
Color onSurface = null, |
|||
Color onBackground = null, |
|||
Color onError = null, |
|||
Brightness brightness = Brightness.light |
|||
) { |
|||
primary = primary ?? new Color(0xFF6200EE); |
|||
primaryVariant = primaryVariant ?? new Color(0xFF3700B3); |
|||
secondary = secondary ?? new Color(0xFF03DAC6); |
|||
secondaryVariant = secondaryVariant ?? new Color(0xFF018786); |
|||
surface = surface ?? Colors.white; |
|||
background = background ?? Colors.white; |
|||
error = error ?? new Color(0xFFB00020); |
|||
onPrimary = onPrimary ?? Colors.white; |
|||
onSecondary = onSecondary ?? Colors.black; |
|||
onSurface = onSurface ?? Colors.black; |
|||
onBackground = onBackground ?? Colors.black; |
|||
onError = onError ?? Colors.white; |
|||
|
|||
return new ColorScheme( |
|||
primary: primary, |
|||
primaryVariant: primaryVariant, |
|||
secondary: secondary, |
|||
secondaryVariant: secondaryVariant, |
|||
surface: surface, |
|||
background: background, |
|||
error: error, |
|||
onPrimary: onPrimary, |
|||
onSecondary: onSecondary, |
|||
onSurface: onSurface, |
|||
onBackground: onBackground, |
|||
onError: onError, |
|||
brightness: brightness |
|||
); |
|||
} |
|||
|
|||
public static ColorScheme dark( |
|||
Color primary = null, |
|||
Color primaryVariant = null, |
|||
Color secondary = null, |
|||
Color secondaryVariant = null, |
|||
Color surface = null, |
|||
Color background = null, |
|||
Color error = null, |
|||
Color onPrimary = null, |
|||
Color onSecondary = null, |
|||
Color onSurface = null, |
|||
Color onBackground = null, |
|||
Color onError = null, |
|||
Brightness brightness = Brightness.dark |
|||
) { |
|||
primary = primary ?? new Color(0xFFBB86FC); |
|||
primaryVariant = primaryVariant ?? new Color(0xFF4B01D0); |
|||
secondary = secondary ?? new Color(0xFF03DAC6); |
|||
secondaryVariant = secondaryVariant ?? new Color(0xFF03DAC6); |
|||
surface = surface ?? Colors.black; |
|||
background = background ?? Colors.black; |
|||
error = error ?? new Color(0xFFB00020); |
|||
onPrimary = onPrimary ?? Colors.black; |
|||
onSecondary = onSecondary ?? Colors.black; |
|||
onSurface = onSurface ?? Colors.white; |
|||
onBackground = onBackground ?? Colors.white; |
|||
onError = onError ?? Colors.black; |
|||
|
|||
return new ColorScheme( |
|||
primary: primary, |
|||
primaryVariant: primaryVariant, |
|||
secondary: secondary, |
|||
secondaryVariant: secondaryVariant, |
|||
surface: surface, |
|||
background: background, |
|||
error: error, |
|||
onPrimary: onPrimary, |
|||
onSecondary: onSecondary, |
|||
onSurface: onSurface, |
|||
onBackground: onBackground, |
|||
onError: onError, |
|||
brightness: brightness |
|||
); |
|||
} |
|||
|
|||
public static ColorScheme fromSwatch( |
|||
MaterialColor primarySwatch = null, |
|||
Color primaryColorDark = null, |
|||
Color accentColor = null, |
|||
Color cardColor = null, |
|||
Color backgroundColor = null, |
|||
Color errorColor = null, |
|||
Brightness? brightness = Brightness.light) { |
|||
D.assert(brightness != null); |
|||
primarySwatch = primarySwatch ?? Colors.blue; |
|||
|
|||
bool isDark = brightness == Brightness.dark; |
|||
bool primaryIsDark = _brightnessFor(primarySwatch) == Brightness.dark; |
|||
Color secondary = accentColor ?? (isDark ? Colors.tealAccent[200] : primarySwatch); |
|||
bool secondaryIsDark = _brightnessFor(secondary) == Brightness.dark; |
|||
|
|||
return new ColorScheme( |
|||
primary: primarySwatch, |
|||
primaryVariant: primaryColorDark ?? (isDark ? Colors.black : primarySwatch[700]), |
|||
secondary: secondary, |
|||
secondaryVariant: isDark ? Colors.tealAccent[700] : primarySwatch[700], |
|||
surface: cardColor ?? (isDark ? Colors.grey[800] : Colors.white), |
|||
background: backgroundColor ?? (isDark ? Colors.grey[700] : primarySwatch[200]), |
|||
error: errorColor ?? Colors.red[700], |
|||
onPrimary: primaryIsDark ? Colors.white : Colors.black, |
|||
onSecondary: secondaryIsDark ? Colors.white : Colors.black, |
|||
onSurface: isDark ? Colors.white : Colors.black, |
|||
onBackground: primaryIsDark ? Colors.white : Colors.black, |
|||
onError: isDark ? Colors.black : Colors.white, |
|||
brightness: brightness ?? Brightness.light |
|||
); |
|||
} |
|||
|
|||
|
|||
static Brightness _brightnessFor(Color color) { |
|||
return ThemeData.estimateBrightnessForColor(color); |
|||
} |
|||
|
|||
|
|||
public readonly Color primary; |
|||
|
|||
public readonly Color primaryVariant; |
|||
|
|||
public readonly Color secondary; |
|||
|
|||
public readonly Color secondaryVariant; |
|||
|
|||
public readonly Color surface; |
|||
|
|||
public readonly Color background; |
|||
|
|||
public readonly Color error; |
|||
|
|||
public readonly Color onPrimary; |
|||
|
|||
public readonly Color onSecondary; |
|||
|
|||
public readonly Color onSurface; |
|||
|
|||
public readonly Color onBackground; |
|||
|
|||
public readonly Color onError; |
|||
|
|||
public readonly Brightness brightness; |
|||
|
|||
public ColorScheme copyWith( |
|||
Color primary = null, |
|||
Color primaryVariant = null, |
|||
Color secondary = null, |
|||
Color secondaryVariant = null, |
|||
Color surface = null, |
|||
Color background = null, |
|||
Color error = null, |
|||
Color onPrimary = null, |
|||
Color onSecondary = null, |
|||
Color onSurface = null, |
|||
Color onBackground = null, |
|||
Color onError = null, |
|||
Brightness? brightness = null) { |
|||
return new ColorScheme( |
|||
primary: primary ?? this.primary, |
|||
primaryVariant: primaryVariant ?? this.primaryVariant, |
|||
secondary: secondary ?? this.secondary, |
|||
secondaryVariant: secondaryVariant ?? this.secondaryVariant, |
|||
surface: surface ?? this.surface, |
|||
background: background ?? this.background, |
|||
error: error ?? this.error, |
|||
onPrimary: onPrimary ?? this.onPrimary, |
|||
onSecondary: onSecondary ?? this.onSecondary, |
|||
onSurface: onSurface ?? this.onSurface, |
|||
onBackground: onBackground ?? this.onBackground, |
|||
onError: onError ?? this.onError, |
|||
brightness: brightness ?? this.brightness |
|||
); |
|||
} |
|||
|
|||
public static ColorScheme lerp(ColorScheme a, ColorScheme b, float t) { |
|||
return new ColorScheme( |
|||
primary: Color.lerp(a.primary, b.primary, t), |
|||
primaryVariant: Color.lerp(a.primaryVariant, b.primaryVariant, t), |
|||
secondary: Color.lerp(a.secondary, b.secondary, t), |
|||
secondaryVariant: Color.lerp(a.secondaryVariant, b.secondaryVariant, t), |
|||
surface: Color.lerp(a.surface, b.surface, t), |
|||
background: Color.lerp(a.background, b.background, t), |
|||
error: Color.lerp(a.error, b.error, t), |
|||
onPrimary: Color.lerp(a.onPrimary, b.onPrimary, t), |
|||
onSecondary: Color.lerp(a.onSecondary, b.onSecondary, t), |
|||
onSurface: Color.lerp(a.onSurface, b.onSurface, t), |
|||
onBackground: Color.lerp(a.onBackground, b.onBackground, t), |
|||
onError: Color.lerp(a.onError, b.onError, t), |
|||
brightness: t < 0.5 ? a.brightness : b.brightness |
|||
); |
|||
} |
|||
|
|||
|
|||
public bool Equals(ColorScheme other) { |
|||
if (ReferenceEquals(null, other)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, other)) { |
|||
return true; |
|||
} |
|||
|
|||
return other.primary == primary |
|||
&& other.primaryVariant == primaryVariant |
|||
&& other.secondary == secondary |
|||
&& other.secondaryVariant == secondaryVariant |
|||
&& other.surface == surface |
|||
&& other.background == background |
|||
&& other.error == error |
|||
&& other.onPrimary == onPrimary |
|||
&& other.onSecondary == onSecondary |
|||
&& other.onSurface == onSurface |
|||
&& other.onBackground == onBackground |
|||
&& other.onError == onError |
|||
&& other.brightness == brightness; |
|||
} |
|||
|
|||
public override bool Equals(object obj) { |
|||
if (ReferenceEquals(null, obj)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, obj)) { |
|||
return true; |
|||
} |
|||
|
|||
if (obj.GetType() != GetType()) { |
|||
return false; |
|||
} |
|||
|
|||
return Equals((ColorScheme) obj); |
|||
} |
|||
|
|||
public static bool operator ==(ColorScheme left, ColorScheme right) { |
|||
return Equals(left, right); |
|||
} |
|||
|
|||
public static bool operator !=(ColorScheme left, ColorScheme right) { |
|||
return !Equals(left, right); |
|||
} |
|||
|
|||
public override int GetHashCode() { |
|||
unchecked { |
|||
var hashCode = primary.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ primaryVariant.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ secondary.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ secondaryVariant.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ surface.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ background.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ error.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ onPrimary.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ onSecondary.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ onSurface.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ onBackground.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ onError.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ brightness.GetHashCode(); |
|||
return hashCode; |
|||
} |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
ColorScheme defaultScheme = light(); |
|||
properties.add(new DiagnosticsProperty<Color>("primary", primary, |
|||
defaultValue: defaultScheme.primary)); |
|||
properties.add(new DiagnosticsProperty<Color>("primaryVariant", primaryVariant, |
|||
defaultValue: defaultScheme.primaryVariant)); |
|||
properties.add(new DiagnosticsProperty<Color>("secondary", secondary, |
|||
defaultValue: defaultScheme.secondary)); |
|||
properties.add(new DiagnosticsProperty<Color>("secondaryVariant", secondaryVariant, |
|||
defaultValue: defaultScheme.secondaryVariant)); |
|||
properties.add(new DiagnosticsProperty<Color>("surface", surface, |
|||
defaultValue: defaultScheme.surface)); |
|||
properties.add(new DiagnosticsProperty<Color>("background", background, |
|||
defaultValue: defaultScheme.background)); |
|||
properties.add(new DiagnosticsProperty<Color>("error", error, defaultValue: defaultScheme.error)); |
|||
properties.add(new DiagnosticsProperty<Color>("onPrimary", onPrimary, |
|||
defaultValue: defaultScheme.onPrimary)); |
|||
properties.add(new DiagnosticsProperty<Color>("onSecondary", onSecondary, |
|||
defaultValue: defaultScheme.onSecondary)); |
|||
properties.add(new DiagnosticsProperty<Color>("onSurface", onSurface, |
|||
defaultValue: defaultScheme.onSurface)); |
|||
properties.add(new DiagnosticsProperty<Color>("onBackground", onBackground, |
|||
defaultValue: defaultScheme.onBackground)); |
|||
properties.add(new DiagnosticsProperty<Color>("onError", onError, |
|||
defaultValue: defaultScheme.onError)); |
|||
properties.add(new DiagnosticsProperty<Brightness>("brightness", brightness, |
|||
defaultValue: defaultScheme.brightness)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a610420b7a8ec44bfa84e81a1e5ff449 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: dfc0e036c07e1441d8dbd3158bb6f923 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.UIWidgets.painting; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public static class Constants { |
|||
public const float kToolbarHeight = 56.0f; |
|||
|
|||
public const float kBottomNavigationBarHeight = 56.0f; |
|||
|
|||
public const float kTextTabBarHeight = 48.0f; |
|||
|
|||
public static readonly TimeSpan kThemeChangeDuration = new TimeSpan(0, 0, 0, 0, 200); |
|||
|
|||
public const float kRadialReactionRadius = 20.0f; |
|||
|
|||
public static readonly TimeSpan kRadialReactionDuration = new TimeSpan(0, 0, 0, 0, 100); |
|||
|
|||
public const int kRadialReactionAlpha = 0x1F; |
|||
|
|||
public static readonly TimeSpan kTabScrollDuration = new TimeSpan(0, 0, 0, 0, 300); |
|||
|
|||
public static readonly EdgeInsets kTabLabelPadding = EdgeInsets.symmetric(horizontal: 16.0f); |
|||
|
|||
public static readonly EdgeInsets kMaterialListPadding = EdgeInsets.symmetric(vertical: 8.0f); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0364fdae877454fb1babca8f67c2561e |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 353f6a1d0791640349fe94187f15ad33 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 2aa14ff76c10f4d459b55674f0a2b57f |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 96f34a8540bb74c7687149b4b2514998 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 068260026dcf947b0af4c9d7f706ab97 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 9a7302f1a187741b88618822daf7a657 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 7c1f7bd49df00452d9a3be75a9e7b213 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: ea3964e7af24d4b059ac6e10ec862a3b |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.ui; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class TextTheme : Diagnosticable, IEquatable<TextTheme> { |
|||
public TextTheme( |
|||
TextStyle display4 = null, |
|||
TextStyle display3 = null, |
|||
TextStyle display2 = null, |
|||
TextStyle display1 = null, |
|||
TextStyle headline = null, |
|||
TextStyle title = null, |
|||
TextStyle subhead = null, |
|||
TextStyle body2 = null, |
|||
TextStyle body1 = null, |
|||
TextStyle caption = null, |
|||
TextStyle button = null, |
|||
TextStyle subtitle = null, |
|||
TextStyle overline = null |
|||
) { |
|||
this.display4 = display4; |
|||
this.display3 = display3; |
|||
this.display2 = display2; |
|||
this.display1 = display1; |
|||
this.headline = headline; |
|||
this.title = title; |
|||
this.subhead = subhead; |
|||
this.body2 = body2; |
|||
this.body1 = body1; |
|||
this.caption = caption; |
|||
this.button = button; |
|||
this.subtitle = subtitle; |
|||
this.overline = overline; |
|||
} |
|||
|
|||
|
|||
public readonly TextStyle display4; |
|||
|
|||
public readonly TextStyle display3; |
|||
|
|||
public readonly TextStyle display2; |
|||
|
|||
public readonly TextStyle display1; |
|||
|
|||
public readonly TextStyle headline; |
|||
|
|||
public readonly TextStyle title; |
|||
|
|||
public readonly TextStyle subhead; |
|||
|
|||
public readonly TextStyle body2; |
|||
|
|||
public readonly TextStyle body1; |
|||
|
|||
public readonly TextStyle caption; |
|||
|
|||
public readonly TextStyle button; |
|||
|
|||
public readonly TextStyle subtitle; |
|||
|
|||
public readonly TextStyle overline; |
|||
|
|||
|
|||
public TextTheme copyWith( |
|||
TextStyle display4 = null, |
|||
TextStyle display3 = null, |
|||
TextStyle display2 = null, |
|||
TextStyle display1 = null, |
|||
TextStyle headline = null, |
|||
TextStyle title = null, |
|||
TextStyle subhead = null, |
|||
TextStyle body2 = null, |
|||
TextStyle body1 = null, |
|||
TextStyle caption = null, |
|||
TextStyle button = null, |
|||
TextStyle subtitle = null, |
|||
TextStyle overline = null |
|||
) { |
|||
return new TextTheme( |
|||
display4: display4 ?? this.display4, |
|||
display3: display3 ?? this.display3, |
|||
display2: display2 ?? this.display2, |
|||
display1: display1 ?? this.display1, |
|||
headline: headline ?? this.headline, |
|||
title: title ?? this.title, |
|||
subhead: subhead ?? this.subhead, |
|||
body2: body2 ?? this.body2, |
|||
body1: body1 ?? this.body1, |
|||
caption: caption ?? this.caption, |
|||
button: button ?? this.button, |
|||
subtitle: subtitle ?? this.subtitle, |
|||
overline: overline ?? this.overline |
|||
); |
|||
} |
|||
|
|||
public TextTheme merge(TextTheme other) { |
|||
if (other == null) { |
|||
return this; |
|||
} |
|||
|
|||
return copyWith( |
|||
display4: display4?.merge(other.display4) ?? other.display4, |
|||
display3: display3?.merge(other.display3) ?? other.display3, |
|||
display2: display2?.merge(other.display2) ?? other.display2, |
|||
display1: display1?.merge(other.display1) ?? other.display1, |
|||
headline: headline?.merge(other.headline) ?? other.headline, |
|||
title: title?.merge(other.title) ?? other.title, |
|||
subhead: subhead?.merge(other.subhead) ?? other.subhead, |
|||
body2: body2?.merge(other.body2) ?? other.body2, |
|||
body1: body1?.merge(other.body1) ?? other.body1, |
|||
caption: caption?.merge(other.caption) ?? other.caption, |
|||
button: button?.merge(other.button) ?? other.button, |
|||
subtitle: subtitle?.merge(other.subtitle) ?? other.subtitle, |
|||
overline: overline?.merge(other.overline) ?? other.overline |
|||
); |
|||
} |
|||
|
|||
|
|||
public TextTheme apply( |
|||
string fontFamily = null, |
|||
float fontSizeFactor = 1.0f, |
|||
float fontSizeDelta = 0.0f, |
|||
Color displayColor = null, |
|||
Color bodyColor = null, |
|||
TextDecoration decoration = null, |
|||
Color decorationColor = null, |
|||
TextDecorationStyle? decorationStyle = null |
|||
) { |
|||
return new TextTheme( |
|||
display4: display4?.apply( |
|||
color: displayColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
display3: display3?.apply( |
|||
color: displayColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
display2: display2?.apply( |
|||
color: displayColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
display1: display1?.apply( |
|||
color: displayColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
headline: headline?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
title: title?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
subhead: subhead?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
body2: body2?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
body1: body1?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
caption: caption?.apply( |
|||
color: displayColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
button: button?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
subtitle: subtitle?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
overline: overline?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
) |
|||
); |
|||
} |
|||
|
|||
public static TextTheme lerp(TextTheme a, TextTheme b, float t) { |
|||
return new TextTheme( |
|||
display4: TextStyle.lerp(a?.display4, b?.display4, t), |
|||
display3: TextStyle.lerp(a?.display3, b?.display3, t), |
|||
display2: TextStyle.lerp(a?.display2, b?.display2, t), |
|||
display1: TextStyle.lerp(a?.display1, b?.display1, t), |
|||
headline: TextStyle.lerp(a?.headline, b?.headline, t), |
|||
title: TextStyle.lerp(a?.title, b?.title, t), |
|||
subhead: TextStyle.lerp(a?.subhead, b?.subhead, t), |
|||
body2: TextStyle.lerp(a?.body2, b?.body2, t), |
|||
body1: TextStyle.lerp(a?.body1, b?.body1, t), |
|||
caption: TextStyle.lerp(a?.caption, b?.caption, t), |
|||
button: TextStyle.lerp(a?.button, b?.button, t), |
|||
subtitle: TextStyle.lerp(a?.subtitle, b?.subtitle, t), |
|||
overline: TextStyle.lerp(a?.overline, b?.overline, t) |
|||
); |
|||
} |
|||
|
|||
public bool Equals(TextTheme other) { |
|||
if (ReferenceEquals(null, other)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, other)) { |
|||
return true; |
|||
} |
|||
|
|||
return display4 == other.display4 |
|||
&& display3 == other.display3 |
|||
&& display2 == other.display2 |
|||
&& display1 == other.display1 |
|||
&& headline == other.headline |
|||
&& title == other.title |
|||
&& subhead == other.subhead |
|||
&& body2 == other.body2 |
|||
&& body1 == other.body1 |
|||
&& caption == other.caption |
|||
&& button == other.button |
|||
&& subtitle == other.subtitle |
|||
&& overline == other.overline; |
|||
} |
|||
|
|||
public override bool Equals(object obj) { |
|||
if (ReferenceEquals(null, obj)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, obj)) { |
|||
return true; |
|||
} |
|||
|
|||
if (obj.GetType() != GetType()) { |
|||
return false; |
|||
} |
|||
|
|||
return Equals((TextTheme) obj); |
|||
} |
|||
|
|||
public static bool operator ==(TextTheme left, TextTheme right) { |
|||
return Equals(left, right); |
|||
} |
|||
|
|||
public static bool operator !=(TextTheme left, TextTheme right) { |
|||
return !Equals(left, right); |
|||
} |
|||
|
|||
int? _cachedHashCode = null; |
|||
public override int GetHashCode() { |
|||
if (_cachedHashCode != null) { |
|||
return _cachedHashCode.Value; |
|||
} |
|||
unchecked { |
|||
var hashCode = display4?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ display3?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ display2?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ display1?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ headline?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ title?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ subhead?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ body2?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ body1?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ caption?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ button?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ subtitle?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ overline?.GetHashCode() ?? 0; |
|||
|
|||
_cachedHashCode = hashCode; |
|||
return hashCode; |
|||
} |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
TextTheme defaultTheme = new Typography().black; |
|||
properties.add(new DiagnosticsProperty<TextStyle>("display4", display4, |
|||
defaultValue: defaultTheme.display4)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("display3", display3, |
|||
defaultValue: defaultTheme.display3)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("display2", display2, |
|||
defaultValue: defaultTheme.display2)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("display1", display1, |
|||
defaultValue: defaultTheme.display1)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("headline", headline, |
|||
defaultValue: defaultTheme.headline)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("title", title, defaultValue: defaultTheme.title)); |
|||
properties.add( |
|||
new DiagnosticsProperty<TextStyle>("subhead", subhead, defaultValue: defaultTheme.subhead)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("body2", body2, defaultValue: defaultTheme.body2)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("body1", body1, defaultValue: defaultTheme.body1)); |
|||
properties.add( |
|||
new DiagnosticsProperty<TextStyle>("caption", caption, defaultValue: defaultTheme.caption)); |
|||
properties.add( |
|||
new DiagnosticsProperty<TextStyle>("button", button, defaultValue: defaultTheme.button)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("subtitle)", subtitle, |
|||
defaultValue: defaultTheme.subtitle)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("overline", overline, |
|||
defaultValue: defaultTheme.overline)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 48eff72daf6ec48e5805ff0698990499 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public static class ThemeUtils { |
|||
public static readonly TimeSpan kThemeAnimationDuration = new TimeSpan(0, 0, 0, 0, 200); |
|||
} |
|||
|
|||
public class Theme : StatelessWidget { |
|||
public Theme( |
|||
Key key = null, |
|||
ThemeData data = null, |
|||
bool isMaterialAppTheme = false, |
|||
Widget child = null |
|||
) : base(key: key) { |
|||
D.assert(child != null); |
|||
D.assert(data != null); |
|||
this.data = data; |
|||
this.isMaterialAppTheme = isMaterialAppTheme; |
|||
this.child = child; |
|||
} |
|||
|
|||
public readonly ThemeData data; |
|||
|
|||
public readonly bool isMaterialAppTheme; |
|||
|
|||
readonly Widget child; |
|||
|
|||
static readonly ThemeData _kFallbackTheme = ThemeData.fallback(); |
|||
|
|||
public static ThemeData of(BuildContext context, bool shadowThemeOnly = false) { |
|||
_InheritedTheme inheritedTheme = |
|||
(_InheritedTheme) context.inheritFromWidgetOfExactType(typeof(_InheritedTheme)); |
|||
if (shadowThemeOnly) { |
|||
if (inheritedTheme == null || inheritedTheme.theme.isMaterialAppTheme) { |
|||
return null; |
|||
} |
|||
|
|||
return inheritedTheme.theme.data; |
|||
} |
|||
|
|||
MaterialLocalizations localizations = MaterialLocalizations.of(context); |
|||
ScriptCategory category = ScriptCategory.englishLike; |
|||
ThemeData theme = inheritedTheme?.theme?.data ?? _kFallbackTheme; |
|||
return ThemeData.localize(theme, theme.typography.geometryThemeFor(category)); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new _InheritedTheme( |
|||
theme: this, |
|||
child: new IconTheme( |
|||
data: data.iconTheme, |
|||
child: child |
|||
) |
|||
); |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
properties.add(new DiagnosticsProperty<ThemeData>("data", data, showName: false)); |
|||
} |
|||
} |
|||
|
|||
|
|||
class _InheritedTheme : InheritedWidget { |
|||
public _InheritedTheme( |
|||
Key key = null, |
|||
Theme theme = null, |
|||
Widget child = null) : base(key: key, child: child) { |
|||
D.assert(theme != null); |
|||
D.assert(child != null); |
|||
this.theme = theme; |
|||
} |
|||
|
|||
public readonly Theme theme; |
|||
|
|||
public override bool updateShouldNotify(InheritedWidget old) { |
|||
return theme.data != ((_InheritedTheme) old).theme.data; |
|||
} |
|||
} |
|||
|
|||
class ThemeDataTween : Tween<ThemeData> { |
|||
public ThemeDataTween( |
|||
ThemeData begin = null, |
|||
ThemeData end = null |
|||
) : base(begin: begin, end: end) { |
|||
} |
|||
|
|||
public override ThemeData lerp(float t) { |
|||
return ThemeData.lerp(begin, end, t); |
|||
} |
|||
} |
|||
|
|||
class AnimatedTheme : ImplicitlyAnimatedWidget { |
|||
public AnimatedTheme( |
|||
Key key = null, |
|||
ThemeData data = null, |
|||
bool isMaterialAppTheme = false, |
|||
Curve curve = null, |
|||
TimeSpan? duration = null, |
|||
Widget child = null |
|||
) : base(key: key, curve: curve ?? Curves.linear, duration: duration ?? ThemeUtils.kThemeAnimationDuration) { |
|||
D.assert(child != null); |
|||
D.assert(data != null); |
|||
this.data = data; |
|||
this.isMaterialAppTheme = isMaterialAppTheme; |
|||
this.child = child; |
|||
} |
|||
|
|||
|
|||
public readonly ThemeData data; |
|||
|
|||
public readonly bool isMaterialAppTheme; |
|||
|
|||
public readonly Widget child; |
|||
|
|||
public override State createState() { |
|||
return new _AnimatedThemeState(); |
|||
} |
|||
} |
|||
|
|||
|
|||
class _AnimatedThemeState : AnimatedWidgetBaseState<AnimatedTheme> { |
|||
ThemeDataTween _data; |
|||
|
|||
protected override void forEachTween(TweenVisitor visitor) { |
|||
_data = (ThemeDataTween) visitor.visit(this, _data, widget.data, |
|||
(ThemeData value) => new ThemeDataTween(begin: value)); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new Theme( |
|||
isMaterialAppTheme: widget.isMaterialAppTheme, |
|||
child: widget.child, |
|||
data: _data.evaluate(animation) |
|||
); |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder description) { |
|||
base.debugFillProperties(description); |
|||
description.add( |
|||
new DiagnosticsProperty<ThemeDataTween>("data", _data, showName: false, defaultValue: null)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8aeba6b651be2405387572671ac527f6 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 68fb5edae4e8440669205d4e5b27ea30 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.ui; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public enum ScriptCategory { |
|||
englishLike, |
|||
|
|||
dense, |
|||
|
|||
tall |
|||
} |
|||
|
|||
|
|||
public class Typography : Diagnosticable { |
|||
public Typography( |
|||
TextTheme black = null, |
|||
TextTheme white = null, |
|||
TextTheme englishLike = null, |
|||
TextTheme dense = null, |
|||
TextTheme tall = null |
|||
) { |
|||
black = black ?? blackMountainView; |
|||
white = white ?? whiteMountainView; |
|||
englishLike = englishLike ?? englishLike2014; |
|||
dense = dense ?? dense2014; |
|||
tall = tall ?? tall2014; |
|||
|
|||
D.assert(black != null); |
|||
D.assert(white != null); |
|||
D.assert(englishLike != null); |
|||
D.assert(dense != null); |
|||
D.assert(tall != null); |
|||
|
|||
this.black = black; |
|||
this.white = white; |
|||
this.englishLike = englishLike; |
|||
this.dense = dense; |
|||
this.tall = tall; |
|||
} |
|||
|
|||
|
|||
public readonly TextTheme black; |
|||
|
|||
public readonly TextTheme white; |
|||
|
|||
public readonly TextTheme englishLike; |
|||
|
|||
public readonly TextTheme dense; |
|||
|
|||
public readonly TextTheme tall; |
|||
|
|||
public TextTheme geometryThemeFor(ScriptCategory category) { |
|||
switch (category) { |
|||
case ScriptCategory.englishLike: |
|||
return englishLike; |
|||
case ScriptCategory.dense: |
|||
return dense; |
|||
case ScriptCategory.tall: |
|||
return tall; |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
|
|||
|
|||
public Typography copyWith( |
|||
TextTheme black = null, |
|||
TextTheme white = null, |
|||
TextTheme englishLike = null, |
|||
TextTheme dense = null, |
|||
TextTheme tall = null) { |
|||
return new Typography( |
|||
black: black ?? this.black, |
|||
white: white ?? this.white, |
|||
englishLike: englishLike ?? this.englishLike, |
|||
dense: dense ?? this.dense, |
|||
tall: tall ?? this.tall); |
|||
} |
|||
|
|||
public static Typography lerp(Typography a, Typography b, float t) { |
|||
return new Typography( |
|||
black: TextTheme.lerp(a.black, b.black, t), |
|||
white: TextTheme.lerp(a.white, b.white, t), |
|||
englishLike: TextTheme.lerp(a.englishLike, b.englishLike, t), |
|||
dense: TextTheme.lerp(a.dense, b.dense, t), |
|||
tall: TextTheme.lerp(a.tall, b.tall, t) |
|||
); |
|||
} |
|||
|
|||
|
|||
public bool Equals(Typography other) { |
|||
if (ReferenceEquals(null, other)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, other)) { |
|||
return true; |
|||
} |
|||
|
|||
return black == other.black |
|||
&& white == other.white |
|||
&& englishLike == other.englishLike |
|||
&& dense == other.dense |
|||
&& tall == other.tall; |
|||
} |
|||
|
|||
public override bool Equals(object obj) { |
|||
if (ReferenceEquals(null, obj)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, obj)) { |
|||
return true; |
|||
} |
|||
|
|||
if (obj.GetType() != GetType()) { |
|||
return false; |
|||
} |
|||
|
|||
return Equals((Typography) obj); |
|||
} |
|||
|
|||
public static bool operator ==(Typography left, Typography right) { |
|||
return Equals(left, right); |
|||
} |
|||
|
|||
public static bool operator !=(Typography left, Typography right) { |
|||
return !Equals(left, right); |
|||
} |
|||
|
|||
public override int GetHashCode() { |
|||
unchecked { |
|||
var hashCode = black.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ white.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ englishLike.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ dense.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ tall.GetHashCode(); |
|||
return hashCode; |
|||
} |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
Typography defaultTypography = new Typography(); |
|||
properties.add( |
|||
new DiagnosticsProperty<TextTheme>("black", black, defaultValue: defaultTypography.black)); |
|||
properties.add( |
|||
new DiagnosticsProperty<TextTheme>("white", white, defaultValue: defaultTypography.white)); |
|||
properties.add(new DiagnosticsProperty<TextTheme>("englishLike", englishLike, |
|||
defaultValue: defaultTypography.englishLike)); |
|||
properties.add( |
|||
new DiagnosticsProperty<TextTheme>("dense", dense, defaultValue: defaultTypography.dense)); |
|||
properties.add(new DiagnosticsProperty<TextTheme>("tall", tall, defaultValue: defaultTypography.tall)); |
|||
} |
|||
|
|||
public static readonly TextTheme blackMountainView = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "blackMountainView display4", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
display3: new TextStyle(debugLabel: "blackMountainView display3", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
display2: new TextStyle(debugLabel: "blackMountainView display2", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
display1: new TextStyle(debugLabel: "blackMountainView display1", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
headline: new TextStyle(debugLabel: "blackMountainView headline", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
title: new TextStyle(debugLabel: "blackMountainView title", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
subhead: new TextStyle(debugLabel: "blackMountainView subhead", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
body2: new TextStyle(debugLabel: "blackMountainView body2", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
body1: new TextStyle(debugLabel: "blackMountainView body1", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
caption: new TextStyle(debugLabel: "blackMountainView caption", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
button: new TextStyle(debugLabel: "blackMountainView button", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
subtitle: new TextStyle(debugLabel: "blackMountainView subtitle", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black, decoration: TextDecoration.none), |
|||
overline: new TextStyle(debugLabel: "blackMountainView overline", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black, decoration: TextDecoration.none) |
|||
); |
|||
|
|||
public static readonly TextTheme whiteMountainView = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "whiteMountainView display4", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
display3: new TextStyle(debugLabel: "whiteMountainView display3", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
display2: new TextStyle(debugLabel: "whiteMountainView display2", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
display1: new TextStyle(debugLabel: "whiteMountainView display1", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
headline: new TextStyle(debugLabel: "whiteMountainView headline", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
title: new TextStyle(debugLabel: "whiteMountainView title", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
subhead: new TextStyle(debugLabel: "whiteMountainView subhead", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
body2: new TextStyle(debugLabel: "whiteMountainView body2", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
body1: new TextStyle(debugLabel: "whiteMountainView body1", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
caption: new TextStyle(debugLabel: "whiteMountainView caption", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
button: new TextStyle(debugLabel: "whiteMountainView button", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
subtitle: new TextStyle(debugLabel: "whiteMountainView subtitle", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
overline: new TextStyle(debugLabel: "whiteMountainView overline", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none) |
|||
); |
|||
|
|||
public static readonly TextTheme blackCupertino = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "blackCupertino display4", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
display3: new TextStyle(debugLabel: "blackCupertino display3", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
display2: new TextStyle(debugLabel: "blackCupertino display2", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
display1: new TextStyle(debugLabel: "blackCupertino display1", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
headline: new TextStyle(debugLabel: "blackCupertino headline", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
title: new TextStyle(debugLabel: "blackCupertino title", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
subhead: new TextStyle(debugLabel: "blackCupertino subhead", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
body2: new TextStyle(debugLabel: "blackCupertino body2", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
body1: new TextStyle(debugLabel: "blackCupertino body1", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
caption: new TextStyle(debugLabel: "blackCupertino caption", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
button: new TextStyle(debugLabel: "blackCupertino button", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
subtitle: new TextStyle(debugLabel: "blackCupertino subtitle", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.black, decoration: TextDecoration.none), |
|||
overline: new TextStyle(debugLabel: "blackCupertino overline", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.black, decoration: TextDecoration.none) |
|||
); |
|||
|
|||
public static readonly TextTheme whiteCupertino = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "whiteCupertino display4", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
display3: new TextStyle(debugLabel: "whiteCupertino display3", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
display2: new TextStyle(debugLabel: "whiteCupertino display2", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
display1: new TextStyle(debugLabel: "whiteCupertino display1", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
headline: new TextStyle(debugLabel: "whiteCupertino headline", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
title: new TextStyle(debugLabel: "whiteCupertino title", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
subhead: new TextStyle(debugLabel: "whiteCupertino subhead", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
body2: new TextStyle(debugLabel: "whiteCupertino body2", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
body1: new TextStyle(debugLabel: "whiteCupertino body1", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
caption: new TextStyle(debugLabel: "whiteCupertino caption", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
button: new TextStyle(debugLabel: "whiteCupertino button", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
subtitle: new TextStyle(debugLabel: "whiteCupertino subtitle", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
overline: new TextStyle(debugLabel: "whiteCupertino overline", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none) |
|||
); |
|||
|
|||
|
|||
public static readonly TextTheme englishLike2014 = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "englishLike display4 2014", inherit: false, fontSize: 112.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
display3: new TextStyle(debugLabel: "englishLike display3 2014", inherit: false, fontSize: 56.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
display2: new TextStyle(debugLabel: "englishLike display2 2014", inherit: false, fontSize: 45.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
display1: new TextStyle(debugLabel: "englishLike display1 2014", inherit: false, fontSize: 34.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
headline: new TextStyle(debugLabel: "englishLike headline 2014", inherit: false, fontSize: 24.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
title: new TextStyle(debugLabel: "englishLike title 2014", inherit: false, fontSize: 20.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
subhead: new TextStyle(debugLabel: "englishLike subhead 2014", inherit: false, fontSize: 16.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
body2: new TextStyle(debugLabel: "englishLike body2 2014", inherit: false, fontSize: 14.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
body1: new TextStyle(debugLabel: "englishLike body1 2014", inherit: false, fontSize: 14.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
caption: new TextStyle(debugLabel: "englishLike caption 2014", inherit: false, fontSize: 12.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
button: new TextStyle(debugLabel: "englishLike button 2014", inherit: false, fontSize: 14.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
subtitle: new TextStyle(debugLabel: "englishLike subtitle 2014", inherit: false, fontSize: 14.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.1f), |
|||
overline: new TextStyle(debugLabel: "englishLike overline 2014", inherit: false, fontSize: 10.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 1.5f) |
|||
); |
|||
|
|||
public static readonly TextTheme englishLike2018 = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "englishLike display4 2018", fontSize: 96.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: -1.5f), |
|||
display3: new TextStyle(debugLabel: "englishLike display3 2018", fontSize: 60.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: -0.5f), |
|||
display2: new TextStyle(debugLabel: "englishLike display2 2018", fontSize: 48.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.0f), |
|||
display1: new TextStyle(debugLabel: "englishLike display1 2018", fontSize: 34.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.25f), |
|||
headline: new TextStyle(debugLabel: "englishLike headline 2018", fontSize: 24.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.0f), |
|||
title: new TextStyle(debugLabel: "englishLike title 2018", fontSize: 20.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.15f), |
|||
subhead: new TextStyle(debugLabel: "englishLike subhead 2018", fontSize: 16.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.15f), |
|||
body2: new TextStyle(debugLabel: "englishLike body2 2018", fontSize: 14.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.25f), |
|||
body1: new TextStyle(debugLabel: "englishLike body1 2018", fontSize: 16.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.5f), |
|||
button: new TextStyle(debugLabel: "englishLike button 2018", fontSize: 14.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.75f), |
|||
caption: new TextStyle(debugLabel: "englishLike caption 2018", fontSize: 12.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.4f), |
|||
subtitle: new TextStyle(debugLabel: "englishLike subtitle 2018", fontSize: 14.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.1f), |
|||
overline: new TextStyle(debugLabel: "englishLike overline 2018", fontSize: 10.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 1.5f) |
|||
); |
|||
|
|||
public static readonly TextTheme dense2014 = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "dense display4 2014", inherit: false, fontSize: 112.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
display3: new TextStyle(debugLabel: "dense display3 2014", inherit: false, fontSize: 56.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
display2: new TextStyle(debugLabel: "dense display2 2014", inherit: false, fontSize: 45.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
display1: new TextStyle(debugLabel: "dense display1 2014", inherit: false, fontSize: 34.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
headline: new TextStyle(debugLabel: "dense headline 2014", inherit: false, fontSize: 24.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
title: new TextStyle(debugLabel: "dense title 2014", inherit: false, fontSize: 21.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
subhead: new TextStyle(debugLabel: "dense subhead 2014", inherit: false, fontSize: 17.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
body2: new TextStyle(debugLabel: "dense body2 2014", inherit: false, fontSize: 15.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
body1: new TextStyle(debugLabel: "dense body1 2014", inherit: false, fontSize: 15.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
caption: new TextStyle(debugLabel: "dense caption 2014", inherit: false, fontSize: 13.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
button: new TextStyle(debugLabel: "dense button 2014", inherit: false, fontSize: 15.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
subtitle: new TextStyle(debugLabel: "dense subtitle 2014", inherit: false, fontSize: 15.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
overline: new TextStyle(debugLabel: "dense overline 2014", inherit: false, fontSize: 11.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic) |
|||
); |
|||
|
|||
public static readonly TextTheme dense2018 = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "dense display4 2018", fontSize: 96.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
display3: new TextStyle(debugLabel: "dense display3 2018", fontSize: 60.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
display2: new TextStyle(debugLabel: "dense display2 2018", fontSize: 48.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
display1: new TextStyle(debugLabel: "dense display1 2018", fontSize: 34.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
headline: new TextStyle(debugLabel: "dense headline 2018", fontSize: 24.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
title: new TextStyle(debugLabel: "dense title 2018", fontSize: 21.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
subhead: new TextStyle(debugLabel: "dense subhead 2018", fontSize: 17.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
body2: new TextStyle(debugLabel: "dense body2 2018", fontSize: 17.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
body1: new TextStyle(debugLabel: "dense body1 2018", fontSize: 15.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
caption: new TextStyle(debugLabel: "dense caption 2018", fontSize: 13.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
button: new TextStyle(debugLabel: "dense button 2018", fontSize: 15.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
subtitle: new TextStyle(debugLabel: "dense subtitle 2018", fontSize: 15.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
overline: new TextStyle(debugLabel: "dense overline 2018", fontSize: 11.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic) |
|||
); |
|||
|
|||
|
|||
public static readonly TextTheme tall2014 = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "tall display4 2014", inherit: false, fontSize: 112.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
display3: new TextStyle(debugLabel: "tall display3 2014", inherit: false, fontSize: 56.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
display2: new TextStyle(debugLabel: "tall display2 2014", inherit: false, fontSize: 45.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
display1: new TextStyle(debugLabel: "tall display1 2014", inherit: false, fontSize: 34.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
headline: new TextStyle(debugLabel: "tall headline 2014", inherit: false, fontSize: 24.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
title: new TextStyle(debugLabel: "tall title 2014", inherit: false, fontSize: 21.0f, |
|||
fontWeight: FontWeight.w700, textBaseline: TextBaseline.alphabetic), |
|||
subhead: new TextStyle(debugLabel: "tall subhead 2014", inherit: false, fontSize: 17.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
body2: new TextStyle(debugLabel: "tall body2 2014", inherit: false, fontSize: 15.0f, |
|||
fontWeight: FontWeight.w700, textBaseline: TextBaseline.alphabetic), |
|||
body1: new TextStyle(debugLabel: "tall body1 2014", inherit: false, fontSize: 15.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
caption: new TextStyle(debugLabel: "tall caption 2014", inherit: false, fontSize: 13.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
button: new TextStyle(debugLabel: "tall button 2014", inherit: false, fontSize: 15.0f, |
|||
fontWeight: FontWeight.w700, textBaseline: TextBaseline.alphabetic), |
|||
subtitle: new TextStyle(debugLabel: "tall subtitle 2014", inherit: false, fontSize: 15.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
overline: new TextStyle(debugLabel: "tall overline 2014", inherit: false, fontSize: 11.0f, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic) |
|||
); |
|||
|
|||
public static readonly TextTheme tall2018 = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "tall display4 2018", fontSize: 96.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
display3: new TextStyle(debugLabel: "tall display3 2018", fontSize: 60.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
display2: new TextStyle(debugLabel: "tall display2 2018", fontSize: 48.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
display1: new TextStyle(debugLabel: "tall display1 2018", fontSize: 34.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
headline: new TextStyle(debugLabel: "tall headline 2018", fontSize: 24.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
title: new TextStyle(debugLabel: "tall title 2018", fontSize: 21.0f, fontWeight: FontWeight.w700, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
subhead: new TextStyle(debugLabel: "tall subhead 2018", fontSize: 17.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
body2: new TextStyle(debugLabel: "tall body2 2018", fontSize: 17.0f, fontWeight: FontWeight.w700, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
body1: new TextStyle(debugLabel: "tall body1 2018", fontSize: 15.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
button: new TextStyle(debugLabel: "tall button 2018", fontSize: 15.0f, fontWeight: FontWeight.w700, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
caption: new TextStyle(debugLabel: "tall caption 2018", fontSize: 13.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
subtitle: new TextStyle(debugLabel: "tall subtitle 2018", fontSize: 15.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
overline: new TextStyle(debugLabel: "tall overline 2018", fontSize: 11.0f, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic) |
|||
); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a7dbdefd2b4fd44dd9ff8d23eb224a31 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.async; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
static class ScrollbarUtils { |
|||
public static readonly TimeSpan _kScrollbarFadeDuration = TimeSpan.FromMilliseconds(300); |
|||
|
|||
public static readonly TimeSpan _kScrollbarTimeToFade = TimeSpan.FromMilliseconds(600); |
|||
|
|||
public const float _kScrollbarThickness = 6.0f; |
|||
} |
|||
|
|||
|
|||
public class Scrollbar : StatefulWidget { |
|||
public Scrollbar( |
|||
Key key = null, |
|||
Widget child = null) : base(key: key) { |
|||
this.child = child; |
|||
} |
|||
|
|||
public readonly Widget child; |
|||
|
|||
public override State createState() { |
|||
return new _ScrollbarState(); |
|||
} |
|||
} |
|||
|
|||
public class _ScrollbarState : TickerProviderStateMixin<Scrollbar> { |
|||
public ScrollbarPainter _materialPainter; |
|||
public TextDirection _textDirection; |
|||
public Color _themeColor; |
|||
|
|||
public AnimationController _fadeoutAnimationController; |
|||
public Animation<float> _FadeoutOpacityAnimation; |
|||
public Timer _fadeoutTimer; |
|||
|
|||
public override void initState() { |
|||
base.initState(); |
|||
_fadeoutAnimationController = new AnimationController( |
|||
vsync: this, |
|||
duration: ScrollbarUtils._kScrollbarFadeDuration |
|||
); |
|||
_FadeoutOpacityAnimation = new CurvedAnimation( |
|||
parent: _fadeoutAnimationController, |
|||
curve: Curves.fastOutSlowIn |
|||
); |
|||
} |
|||
|
|||
public override void didChangeDependencies() { |
|||
base.didChangeDependencies(); |
|||
|
|||
ThemeData theme = Theme.of(context); |
|||
|
|||
_themeColor = theme.highlightColor.withOpacity(1.0f); |
|||
_textDirection = Directionality.of(context); |
|||
_materialPainter = _BuildMaterialScrollbarPainter(); |
|||
} |
|||
|
|||
public ScrollbarPainter _BuildMaterialScrollbarPainter() { |
|||
return new ScrollbarPainter( |
|||
color: _themeColor, |
|||
textDirection: _textDirection, |
|||
thickness: ScrollbarUtils._kScrollbarThickness, |
|||
fadeoutOpacityAnimation: _FadeoutOpacityAnimation |
|||
); |
|||
} |
|||
|
|||
bool _handleScrollNotification(ScrollNotification notification) { |
|||
if (notification is ScrollUpdateNotification || notification is OverscrollNotification) { |
|||
if (_fadeoutAnimationController.status != AnimationStatus.forward) { |
|||
_fadeoutAnimationController.forward(); |
|||
} |
|||
|
|||
_materialPainter.update(notification.metrics, notification.metrics.axisDirection); |
|||
_fadeoutTimer?.cancel(); |
|||
|
|||
_fadeoutTimer = Window.instance.run(ScrollbarUtils._kScrollbarTimeToFade, () => { |
|||
_fadeoutAnimationController.reverse(); |
|||
_fadeoutTimer = null; |
|||
}); |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
public override void dispose() { |
|||
_fadeoutAnimationController.dispose(); |
|||
_fadeoutTimer?.cancel(); |
|||
_materialPainter?.dispose(); |
|||
|
|||
base.dispose(); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new NotificationListener<ScrollNotification>( |
|||
onNotification: _handleScrollNotification, |
|||
child: new RepaintBoundary( |
|||
child: new CustomPaint( |
|||
foregroundPainter: _materialPainter, |
|||
child: new RepaintBoundary( |
|||
child: widget.child |
|||
) |
|||
) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: d8341e3dbe41a48c1b05857eb0d0f7d9 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.ui; |
|||
using UnityEngine; |
|||
using Rect = Unity.UIWidgets.ui.Rect; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
static class ArcUtils { |
|||
public const float _kOnAxisDelta = 2.0f; |
|||
|
|||
public static readonly List<_Diagonal> _allDiagonals = new List<_Diagonal> { |
|||
new _Diagonal(_CornerId.topLeft, _CornerId.bottomRight), |
|||
new _Diagonal(_CornerId.bottomRight, _CornerId.topLeft), |
|||
new _Diagonal(_CornerId.topRight, _CornerId.bottomLeft), |
|||
new _Diagonal(_CornerId.bottomLeft, _CornerId.topRight) |
|||
}; |
|||
|
|||
public delegate float _KeyFunc<T>(T input); |
|||
|
|||
|
|||
public static T _maxBy<T>(List<T> input, _KeyFunc<T> keyFunc) { |
|||
T maxValue = default(T); |
|||
float? maxKey = null; |
|||
foreach (T value in input) { |
|||
float key = keyFunc(value); |
|||
if (maxKey == null || key > maxKey) { |
|||
maxValue = value; |
|||
maxKey = key; |
|||
} |
|||
} |
|||
|
|||
return maxValue; |
|||
} |
|||
} |
|||
|
|||
public class MaterialPointArcTween : Tween<Offset> { |
|||
public MaterialPointArcTween( |
|||
Offset begin = null, |
|||
Offset end = null) : base(begin: begin, end: end) { |
|||
} |
|||
|
|||
bool _dirty = true; |
|||
|
|||
void _initialze() { |
|||
D.assert(begin != null); |
|||
D.assert(end != null); |
|||
|
|||
Offset delta = end - begin; |
|||
float deltaX = delta.dx.abs(); |
|||
float deltaY = delta.dy.abs(); |
|||
float distanceFromAtoB = delta.distance; |
|||
Offset c = new Offset(end.dx, begin.dy); |
|||
|
|||
float sweepAngle() { |
|||
return 2.0f * Mathf.Asin(distanceFromAtoB / (2.0f * _radius)); |
|||
} |
|||
|
|||
if (deltaX > ArcUtils._kOnAxisDelta && deltaY > ArcUtils._kOnAxisDelta) { |
|||
if (deltaX < deltaY) { |
|||
_radius = distanceFromAtoB * distanceFromAtoB / (c - begin).distance / 2.0f; |
|||
_center = new Offset(end.dx + _radius * (begin.dx - end.dx).sign(), |
|||
end.dy); |
|||
if (begin.dx < end.dx) { |
|||
_beginAngle = sweepAngle() * (begin.dy - end.dy).sign(); |
|||
_endAngle = 0.0f; |
|||
} |
|||
else { |
|||
_beginAngle = (Mathf.PI + sweepAngle() * (end.dy - begin.dy).sign()); |
|||
_endAngle = Mathf.PI; |
|||
} |
|||
} |
|||
else { |
|||
_radius = distanceFromAtoB * distanceFromAtoB / (c - end).distance / 2.0f; |
|||
_center = new Offset(begin.dx, |
|||
begin.dy + (end.dy - begin.dy).sign() * _radius); |
|||
if (begin.dy < end.dy) { |
|||
_beginAngle = -Mathf.PI / 2.0f; |
|||
_endAngle = _beginAngle + sweepAngle() * (end.dx - begin.dx).sign(); |
|||
} |
|||
else { |
|||
_beginAngle = Mathf.PI / 2.0f; |
|||
_endAngle = _beginAngle + sweepAngle() * (begin.dx - end.dx).sign(); |
|||
} |
|||
} |
|||
|
|||
D.assert(_beginAngle != null); |
|||
D.assert(_endAngle != null); |
|||
} |
|||
else { |
|||
_beginAngle = null; |
|||
_endAngle = null; |
|||
} |
|||
|
|||
_dirty = false; |
|||
} |
|||
|
|||
public Offset center { |
|||
get { |
|||
if (begin == null || end == null) { |
|||
return null; |
|||
} |
|||
|
|||
if (_dirty) { |
|||
_initialze(); |
|||
} |
|||
|
|||
return _center; |
|||
} |
|||
} |
|||
|
|||
Offset _center; |
|||
|
|||
public float? radius { |
|||
get { |
|||
if (begin == null || end == null) { |
|||
return null; |
|||
} |
|||
|
|||
if (_dirty) { |
|||
_initialze(); |
|||
} |
|||
|
|||
return _radius; |
|||
} |
|||
} |
|||
|
|||
float _radius; |
|||
|
|||
public float? beginAngle { |
|||
get { |
|||
if (begin == null || end == null) { |
|||
return null; |
|||
} |
|||
|
|||
if (_dirty) { |
|||
_initialze(); |
|||
} |
|||
|
|||
return _beginAngle; |
|||
} |
|||
} |
|||
|
|||
float? _beginAngle; |
|||
|
|||
public float? endAngle { |
|||
get { |
|||
if (begin == null || end == null) { |
|||
return null; |
|||
} |
|||
|
|||
if (_dirty) { |
|||
_initialze(); |
|||
} |
|||
|
|||
return _endAngle; |
|||
} |
|||
} |
|||
|
|||
float? _endAngle; |
|||
|
|||
public override Offset begin { |
|||
get { return base.begin; } |
|||
set { |
|||
if (value != base.begin) { |
|||
base.begin = value; |
|||
_dirty = true; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override Offset end { |
|||
get { return base.end; } |
|||
set { |
|||
if (value != base.end) { |
|||
base.end = value; |
|||
_dirty = true; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override Offset lerp(float t) { |
|||
if (_dirty) { |
|||
_initialze(); |
|||
} |
|||
|
|||
if (t == 0.0) { |
|||
return begin; |
|||
} |
|||
|
|||
if (t == 1.0) { |
|||
return end; |
|||
} |
|||
|
|||
if (_beginAngle == null || _endAngle == null) { |
|||
return Offset.lerp(begin, end, t); |
|||
} |
|||
|
|||
float angle = MathUtils.lerpNullableFloat(_beginAngle, _endAngle, t) ?? 0.0f; |
|||
float x = Mathf.Cos(angle) * _radius; |
|||
float y = Mathf.Sin(angle) * _radius; |
|||
return _center + new Offset(x, y); |
|||
} |
|||
|
|||
public override string ToString() { |
|||
return GetType() + "(" + begin + "->" + end + "); center=" + center + |
|||
", radius=" + radius + ", beginAngle=" + beginAngle + ", endAngle=" + endAngle; |
|||
} |
|||
} |
|||
|
|||
public enum _CornerId { |
|||
topLeft, |
|||
topRight, |
|||
bottomLeft, |
|||
bottomRight |
|||
} |
|||
|
|||
public class _Diagonal { |
|||
public _Diagonal( |
|||
_CornerId beginId, |
|||
_CornerId endId) { |
|||
this.beginId = beginId; |
|||
this.endId = endId; |
|||
} |
|||
|
|||
public readonly _CornerId beginId; |
|||
|
|||
public readonly _CornerId endId; |
|||
} |
|||
|
|||
public class MaterialRectArcTween : RectTween { |
|||
public MaterialRectArcTween( |
|||
Rect begin = null, |
|||
Rect end = null) : base(begin: begin, end: end) { |
|||
} |
|||
|
|||
bool _dirty = true; |
|||
|
|||
void _initialize() { |
|||
D.assert(begin != null); |
|||
D.assert(end != null); |
|||
Offset centersVector = end.center - begin.center; |
|||
_Diagonal diagonal = ArcUtils._maxBy(ArcUtils._allDiagonals, |
|||
(_Diagonal d) => _diagonalSupport(centersVector, d)); |
|||
_beginArc = new MaterialPointArcTween( |
|||
begin: _cornerFor(begin, diagonal.beginId), |
|||
end: _cornerFor(end, diagonal.beginId)); |
|||
_endArc = new MaterialPointArcTween( |
|||
begin: _cornerFor(begin, diagonal.endId), |
|||
end: _cornerFor(end, diagonal.endId)); |
|||
_dirty = false; |
|||
} |
|||
|
|||
float _diagonalSupport(Offset centersVector, _Diagonal diagonal) { |
|||
Offset delta = _cornerFor(begin, diagonal.endId) - _cornerFor(begin, diagonal.beginId); |
|||
float length = delta.distance; |
|||
return centersVector.dx * delta.dx / length + centersVector.dy * delta.dy / length; |
|||
} |
|||
|
|||
Offset _cornerFor(Rect rect, _CornerId id) { |
|||
switch (id) { |
|||
case _CornerId.topLeft: return rect.topLeft; |
|||
case _CornerId.topRight: return rect.topRight; |
|||
case _CornerId.bottomLeft: return rect.bottomLeft; |
|||
case _CornerId.bottomRight: return rect.bottomRight; |
|||
} |
|||
|
|||
return Offset.zero; |
|||
} |
|||
|
|||
public MaterialPointArcTween beginArc { |
|||
get { |
|||
if (begin == null) { |
|||
return null; |
|||
} |
|||
|
|||
if (_dirty) { |
|||
_initialize(); |
|||
} |
|||
|
|||
return _beginArc; |
|||
} |
|||
} |
|||
|
|||
MaterialPointArcTween _beginArc; |
|||
|
|||
public MaterialPointArcTween endArc { |
|||
get { |
|||
if (end == null) { |
|||
return null; |
|||
} |
|||
|
|||
if (_dirty) { |
|||
_initialize(); |
|||
} |
|||
|
|||
return _endArc; |
|||
} |
|||
} |
|||
|
|||
MaterialPointArcTween _endArc; |
|||
|
|||
public override Rect begin { |
|||
get { return base.begin; } |
|||
set { |
|||
if (value != base.begin) { |
|||
base.begin = value; |
|||
_dirty = true; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override Rect end { |
|||
get { return base.end; } |
|||
set { |
|||
if (value != base.end) { |
|||
base.end = value; |
|||
_dirty = true; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override Rect lerp(float t) { |
|||
if (_dirty) { |
|||
_initialize(); |
|||
} |
|||
|
|||
if (t == 0.0) { |
|||
return begin; |
|||
} |
|||
|
|||
if (t == 1.0) { |
|||
return end; |
|||
} |
|||
|
|||
return Rect.fromPoints(_beginArc.lerp(t), _endArc.lerp(t)); |
|||
} |
|||
|
|||
public override string ToString() { |
|||
return GetType() + "(" + begin + "->" + end + ")"; |
|||
} |
|||
} |
|||
|
|||
public class MaterialRectCenterArcTween : RectTween { |
|||
public MaterialRectCenterArcTween( |
|||
Rect begin = null, |
|||
Rect end = null) : base(begin: begin, end: end) { |
|||
} |
|||
|
|||
bool _dirty = true; |
|||
|
|||
void _initialize() { |
|||
D.assert(begin != null); |
|||
D.assert(end != null); |
|||
_centerArc = new MaterialPointArcTween( |
|||
begin: begin.center, |
|||
end: end.center); |
|||
_dirty = false; |
|||
} |
|||
|
|||
public MaterialPointArcTween centerArc { |
|||
get { |
|||
if (begin == null || end == null) { |
|||
return null; |
|||
} |
|||
|
|||
if (_dirty) { |
|||
_initialize(); |
|||
} |
|||
|
|||
return _centerArc; |
|||
} |
|||
} |
|||
|
|||
MaterialPointArcTween _centerArc; |
|||
|
|||
|
|||
public override Rect begin { |
|||
get { return base.begin; } |
|||
set { |
|||
if (value != base.begin) { |
|||
base.begin = value; |
|||
_dirty = true; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override Rect end { |
|||
get { return base.end; } |
|||
set { |
|||
if (value != base.end) { |
|||
base.end = value; |
|||
_dirty = true; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override Rect lerp(float t) { |
|||
if (_dirty) { |
|||
_initialize(); |
|||
} |
|||
|
|||
if (t == 0.0) { |
|||
return begin; |
|||
} |
|||
|
|||
if (t == 1.0) { |
|||
return end; |
|||
} |
|||
|
|||
Offset center = _centerArc.lerp(t); |
|||
float width = MathUtils.lerpFloat(begin.width, end.width, t); |
|||
float height = MathUtils.lerpFloat(begin.height, end.height, t); |
|||
return Rect.fromLTWH( |
|||
(center.dx - width / 2.0f), |
|||
(center.dy - height / 2.0f), |
|||
width, |
|||
height); |
|||
} |
|||
|
|||
public override string ToString() { |
|||
return GetType() + "(" + begin + "->" + end + "); centerArc=" + centerArc; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c31d4962cd3d8445a8cd357447154970 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class RawMaterialButton : StatefulWidget { |
|||
public RawMaterialButton( |
|||
Key key = null, |
|||
VoidCallback onPressed = null, |
|||
ValueChanged<bool> onHighlightChanged = null, |
|||
TextStyle textStyle = null, |
|||
Color fillColor = null, |
|||
Color highlightColor = null, |
|||
Color splashColor = null, |
|||
float elevation = 2.0f, |
|||
float highlightElevation = 8.0f, |
|||
float disabledElevation = 0.0f, |
|||
EdgeInsets padding = null, |
|||
BoxConstraints constraints = null, |
|||
ShapeBorder shape = null, |
|||
TimeSpan? animationDuration = null, |
|||
Clip clipBehavior = Clip.none, |
|||
MaterialTapTargetSize? materialTapTargetSize = null, |
|||
Widget child = null) : base(key: key) { |
|||
D.assert(elevation >= 0.0); |
|||
D.assert(highlightElevation >= 0.0); |
|||
D.assert(disabledElevation >= 0.0); |
|||
|
|||
MaterialTapTargetSize _materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded; |
|||
shape = shape ?? new RoundedRectangleBorder(); |
|||
padding = padding ?? EdgeInsets.zero; |
|||
constraints = constraints ?? new BoxConstraints(minWidth: 88.0f, minHeight: 36.0f); |
|||
TimeSpan _animationDuration = animationDuration ?? Constants.kThemeChangeDuration; |
|||
|
|||
this.onPressed = onPressed; |
|||
this.onHighlightChanged = onHighlightChanged; |
|||
this.textStyle = textStyle; |
|||
this.fillColor = fillColor; |
|||
this.highlightColor = highlightColor; |
|||
this.splashColor = splashColor; |
|||
this.elevation = elevation; |
|||
this.highlightElevation = highlightElevation; |
|||
this.disabledElevation = disabledElevation; |
|||
this.padding = padding; |
|||
this.constraints = constraints; |
|||
this.shape = shape; |
|||
this.animationDuration = _animationDuration; |
|||
this.clipBehavior = clipBehavior; |
|||
this.materialTapTargetSize = _materialTapTargetSize; |
|||
this.child = child; |
|||
} |
|||
|
|||
public readonly VoidCallback onPressed; |
|||
|
|||
public readonly ValueChanged<bool> onHighlightChanged; |
|||
|
|||
public readonly TextStyle textStyle; |
|||
|
|||
public readonly Color fillColor; |
|||
|
|||
public readonly Color highlightColor; |
|||
|
|||
public readonly Color splashColor; |
|||
|
|||
public readonly float elevation; |
|||
|
|||
public readonly float highlightElevation; |
|||
|
|||
public readonly float disabledElevation; |
|||
|
|||
public readonly EdgeInsets padding; |
|||
|
|||
public readonly BoxConstraints constraints; |
|||
|
|||
public readonly ShapeBorder shape; |
|||
|
|||
public readonly TimeSpan animationDuration; |
|||
|
|||
public readonly Widget child; |
|||
|
|||
public bool enabled { |
|||
get { return onPressed != null; } |
|||
} |
|||
|
|||
public readonly MaterialTapTargetSize materialTapTargetSize; |
|||
|
|||
public readonly Clip clipBehavior; |
|||
|
|||
public override State createState() { |
|||
return new _RawMaterialButtonState(); |
|||
} |
|||
} |
|||
|
|||
|
|||
class _RawMaterialButtonState : State<RawMaterialButton> { |
|||
bool _highlight = false; |
|||
|
|||
void _handleHighlightChanged(bool value) { |
|||
if (_highlight != value) { |
|||
setState(() => { |
|||
_highlight = value; |
|||
if (widget.onHighlightChanged != null) { |
|||
widget.onHighlightChanged(value); |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
|
|||
public override void didUpdateWidget(StatefulWidget _oldWidget) { |
|||
RawMaterialButton oldWidget = _oldWidget as RawMaterialButton; |
|||
base.didUpdateWidget(oldWidget); |
|||
if (_highlight && !widget.enabled) { |
|||
_highlight = false; |
|||
if (widget.onHighlightChanged != null) { |
|||
widget.onHighlightChanged(false); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
float elevation = widget.enabled |
|||
? (_highlight ? widget.highlightElevation : widget.elevation) |
|||
: widget.disabledElevation; |
|||
|
|||
Widget result = new ConstrainedBox( |
|||
constraints: widget.constraints, |
|||
child: new Material( |
|||
elevation: elevation, |
|||
textStyle: widget.textStyle, |
|||
shape: widget.shape, |
|||
color: widget.fillColor, |
|||
type: widget.fillColor == null ? MaterialType.transparency : MaterialType.button, |
|||
animationDuration: widget.animationDuration, |
|||
clipBehavior: widget.clipBehavior, |
|||
child: new InkWell( |
|||
onHighlightChanged: _handleHighlightChanged, |
|||
splashColor: widget.splashColor, |
|||
highlightColor: widget.highlightColor, |
|||
onTap: widget.onPressed == null |
|||
? (GestureTapCallback) null |
|||
: () => { |
|||
if (widget.onPressed != null) { |
|||
widget.onPressed(); |
|||
} |
|||
}, |
|||
customBorder: widget.shape, |
|||
child: IconTheme.merge( |
|||
data: new IconThemeData(color: widget.textStyle?.color), |
|||
child: new Container( |
|||
padding: widget.padding, |
|||
child: new Center( |
|||
widthFactor: 1.0f, |
|||
heightFactor: 1.0f, |
|||
child: widget.child) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
); |
|||
|
|||
return result; |
|||
} |
|||
} |
|||
} |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class ButtonBar : StatelessWidget { |
|||
public ButtonBar( |
|||
Key key = null, |
|||
MainAxisAlignment alignment = MainAxisAlignment.end, |
|||
MainAxisSize mainAxisSize = MainAxisSize.max, |
|||
List<Widget> children = null |
|||
) : base(key: key) { |
|||
this.alignment = alignment; |
|||
this.mainAxisSize = mainAxisSize; |
|||
this.children = children ?? new List<Widget>(); |
|||
} |
|||
|
|||
public readonly MainAxisAlignment alignment; |
|||
|
|||
public readonly MainAxisSize mainAxisSize; |
|||
|
|||
public readonly List<Widget> children; |
|||
|
|||
|
|||
public override Widget build(BuildContext context) { |
|||
ButtonThemeData buttonTheme = ButtonTheme.of(context); |
|||
float paddingUnit = buttonTheme.padding.horizontal / 4.0f; |
|||
List<Widget> _children = new List<Widget>(); |
|||
foreach (Widget _child in children) { |
|||
_children.Add( |
|||
new Padding( |
|||
padding: EdgeInsets.symmetric(horizontal: paddingUnit), |
|||
child: _child |
|||
) |
|||
); |
|||
} |
|||
|
|||
Widget child = new Row( |
|||
mainAxisAlignment: alignment, |
|||
mainAxisSize: mainAxisSize, |
|||
children: _children |
|||
); |
|||
|
|||
switch (buttonTheme.layoutBehavior) { |
|||
case ButtonBarLayoutBehavior.padded: |
|||
return new Padding( |
|||
padding: EdgeInsets.symmetric( |
|||
vertical: 2.0f * paddingUnit, |
|||
horizontal: paddingUnit |
|||
), |
|||
child: child |
|||
); |
|||
case ButtonBarLayoutBehavior.constrained: |
|||
return new Container( |
|||
padding: EdgeInsets.symmetric(horizontal: paddingUnit), |
|||
constraints: new BoxConstraints(minHeight: 52.0f), |
|||
alignment: Alignment.center, |
|||
child: child |
|||
); |
|||
} |
|||
|
|||
D.assert(false); |
|||
return null; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 2658772190aaa4fa79836ff61595171d |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class Card : StatelessWidget { |
|||
public Card( |
|||
Key key = null, |
|||
Color color = null, |
|||
float? elevation = null, |
|||
ShapeBorder shape = null, |
|||
bool borderOnForeground = true, |
|||
EdgeInsets margin = null, |
|||
Clip? clipBehavior = null, |
|||
Widget child = null) : base(key: key) { |
|||
D.assert(elevation == null || elevation >= 0.0f); |
|||
this.color = color; |
|||
this.elevation = elevation; |
|||
this.shape = shape; |
|||
this.borderOnForeground = borderOnForeground; |
|||
this.margin = margin; |
|||
this.clipBehavior = clipBehavior; |
|||
this.child = child; |
|||
} |
|||
|
|||
public readonly Color color; |
|||
|
|||
public readonly float? elevation; |
|||
|
|||
public readonly ShapeBorder shape; |
|||
|
|||
public readonly bool borderOnForeground; |
|||
|
|||
public readonly Clip? clipBehavior; |
|||
|
|||
public readonly EdgeInsets margin; |
|||
|
|||
public readonly Widget child; |
|||
|
|||
const float _defaultElevation = 1.0f; |
|||
const Clip _defaultClipBehavior = Clip.none; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
CardTheme cardTheme = CardTheme.of(context); |
|||
|
|||
return new Container( |
|||
margin: margin ?? cardTheme.margin ?? EdgeInsets.all(4.0f), |
|||
child: new Material( |
|||
type: MaterialType.card, |
|||
color: color ?? cardTheme.color ?? Theme.of(context).cardColor, |
|||
elevation: elevation ?? cardTheme.elevation ?? _defaultElevation, |
|||
shape: shape ?? cardTheme.shape ?? new RoundedRectangleBorder( |
|||
borderRadius: BorderRadius.all(Radius.circular(4.0f)) |
|||
), |
|||
borderOnForeground: borderOnForeground, |
|||
clipBehavior: clipBehavior ?? cardTheme.clipBehavior ?? _defaultClipBehavior, |
|||
child: child) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 4f7e63a9f1e7d49e7896665f3c16bbe3 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public static class MaterialD { |
|||
public static bool debugCheckHasMaterial(BuildContext context) { |
|||
D.assert(() => { |
|||
if (!(context.widget is Material) && context.ancestorWidgetOfExactType(typeof(Material)) == null) { |
|||
string message = "No Material widget found."; |
|||
message += context.widget.GetType() + " widgets require a Material widget ancestor."; |
|||
|
|||
message += "In material design, most widgets are conceptually \"printed\" on " + |
|||
"a sheet of material. In UIWidgets\'s material library, that " + |
|||
"material is represented by the Material widget. It is the " + |
|||
"Material widget that renders ink splashes, for instance. " + |
|||
"Because of this, many material library widgets require that " + |
|||
"there be a Material widget in the tree above them."; |
|||
|
|||
message += "To introduce a Material widget, you can either directly " + |
|||
"include one, or use a widget that contains Material itself, " + |
|||
"such as a Card, Dialog, Drawer, or Scaffold."; |
|||
|
|||
message += "The specific widget that could not find a Material ancestor was:"; |
|||
|
|||
message += context.widget.ToString(); |
|||
List<Widget> ancestors = new List<Widget>(); |
|||
|
|||
context.visitAncestorElements((Element element) => { |
|||
ancestors.Add(element.widget); |
|||
return true; |
|||
}); |
|||
if (ancestors.isNotEmpty()) { |
|||
message += "The ancestors of this widget were:"; |
|||
foreach (Widget ancestor in ancestors) { |
|||
message += "\n " + ancestor; |
|||
} |
|||
} else { |
|||
message += "This widget is the root of the tree, so it has no " + |
|||
"ancestors, let alone a \"Material\" ancestor."; |
|||
} |
|||
|
|||
throw new UIWidgetsError(message); |
|||
} |
|||
|
|||
return true; |
|||
}); |
|||
return true; |
|||
} |
|||
|
|||
public static bool debugCheckHasMaterialLocalizations(BuildContext context) { |
|||
D.assert(() => { |
|||
if (Localizations.of<MaterialLocalizations>(context, typeof(MaterialLocalizations)) == null) { |
|||
StringBuilder message = new StringBuilder(); |
|||
message.AppendLine("No MaterialLocalizations found."); |
|||
message.AppendLine( |
|||
context.widget.GetType() + " widgets require MaterialLocalizations " + |
|||
"to be provided by a Localizations widget ancestor."); |
|||
message.AppendLine( |
|||
"Localizations are used to generate many different messages, labels," + |
|||
"and abbreviations which are used by the material library. "); |
|||
message.AppendLine( |
|||
"To introduce a MaterialLocalizations, either use a " + |
|||
" MaterialApp at the root of your application to include them " + |
|||
"automatically, or add a Localization widget with a " + |
|||
"MaterialLocalizations delegate."); |
|||
message.AppendLine( |
|||
"The specific widget that could not find a MaterialLocalizations ancestor was:" |
|||
); |
|||
message.AppendLine(" " + context.widget); |
|||
List<Widget> ancestors = new List<Widget>(); |
|||
context.visitAncestorElements((Element element) => { |
|||
ancestors.Add(element.widget); |
|||
return true; |
|||
}); |
|||
if (ancestors.isNotEmpty()) { |
|||
message.Append("The ancestors of this widget were:"); |
|||
foreach (Widget ancestor in ancestors) { |
|||
message.Append("\n " + ancestor); |
|||
} |
|||
} else { |
|||
message.AppendLine( |
|||
"This widget is the root of the tree, so it has no " + |
|||
"ancestors, let alone a \"Localizations\" ancestor." |
|||
); |
|||
} |
|||
throw new UIWidgetsError(message.ToString()); |
|||
} |
|||
return true; |
|||
}); |
|||
return true; |
|||
} |
|||
} |
|||
} |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class Divider : StatelessWidget { |
|||
public Divider( |
|||
Key key = null, |
|||
float height = 16.0f, |
|||
float indent = 0.0f, |
|||
Color color = null) : base(key: key) { |
|||
D.assert(height >= 0.0); |
|||
this.height = height; |
|||
this.indent = indent; |
|||
this.color = color; |
|||
} |
|||
|
|||
public readonly float height; |
|||
|
|||
public readonly float indent; |
|||
|
|||
public readonly Color color; |
|||
|
|||
public static BorderSide createBorderSide(BuildContext context, Color color = null, float width = 0.0f) { |
|||
return new BorderSide( |
|||
color: color ?? Theme.of(context).dividerColor, |
|||
width: width); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new SizedBox( |
|||
height: height, |
|||
child: new Center( |
|||
child: new Container( |
|||
height: 0.0f, |
|||
margin: EdgeInsets.only(indent), |
|||
decoration: new BoxDecoration( |
|||
border: new Border( |
|||
bottom: createBorderSide(context, color: color)) |
|||
) |
|||
) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: defd4aeb126394fa09828fd8ad695931 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
static class DrawerUtils { |
|||
public const float _kWidth = 304.0f; |
|||
public const float _kEdgeDragWidth = 20.0f; |
|||
public const float _kMinFlingVelocity = 365.0f; |
|||
public static readonly TimeSpan _kBaseSettleDuration = new TimeSpan(0, 0, 0, 0, 246); |
|||
} |
|||
|
|||
|
|||
public enum DrawerAlignment { |
|||
start, |
|||
end |
|||
} |
|||
|
|||
public class Drawer : StatelessWidget { |
|||
public Drawer( |
|||
Key key = null, |
|||
float elevation = 16.0f, |
|||
Widget child = null) : base(key: key) { |
|||
D.assert(elevation >= 0.0f); |
|||
this.elevation = elevation; |
|||
this.child = child; |
|||
} |
|||
|
|||
public readonly float elevation; |
|||
|
|||
public readonly Widget child; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new ConstrainedBox( |
|||
constraints: BoxConstraints.expand(width: DrawerUtils._kWidth), |
|||
child: new Material( |
|||
elevation: elevation, |
|||
child: child |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
public delegate void DrawerCallback(bool isOpened); |
|||
|
|||
|
|||
public class DrawerController : StatefulWidget { |
|||
public DrawerController( |
|||
GlobalKey key = null, |
|||
Widget child = null, |
|||
DrawerAlignment? alignment = null, |
|||
DrawerCallback drawerCallback = null, |
|||
DragStartBehavior dragStartBehavior = DragStartBehavior.start |
|||
) : base(key: key) { |
|||
D.assert(child != null); |
|||
D.assert(alignment != null); |
|||
this.child = child; |
|||
this.alignment = alignment ?? DrawerAlignment.start; |
|||
this.drawerCallback = drawerCallback; |
|||
this.dragStartBehavior = dragStartBehavior; |
|||
} |
|||
|
|||
public readonly Widget child; |
|||
|
|||
public readonly DrawerAlignment alignment; |
|||
|
|||
public readonly DragStartBehavior? dragStartBehavior; |
|||
|
|||
public readonly DrawerCallback drawerCallback; |
|||
|
|||
public override State createState() { |
|||
return new DrawerControllerState(); |
|||
} |
|||
} |
|||
|
|||
|
|||
public class DrawerControllerState : SingleTickerProviderStateMixin<DrawerController> { |
|||
public override void initState() { |
|||
base.initState(); |
|||
_controller = new AnimationController(duration: DrawerUtils._kBaseSettleDuration, vsync: this); |
|||
_controller.addListener(_animationChanged); |
|||
_controller.addStatusListener(_animationStatusChanged); |
|||
} |
|||
|
|||
public override void dispose() { |
|||
_historyEntry?.remove(); |
|||
_controller.dispose(); |
|||
base.dispose(); |
|||
} |
|||
|
|||
void _animationChanged() { |
|||
setState(() => { }); |
|||
} |
|||
|
|||
LocalHistoryEntry _historyEntry; |
|||
readonly FocusScopeNode _focusScopeNode = new FocusScopeNode(); |
|||
|
|||
void _ensureHistoryEntry() { |
|||
if (_historyEntry == null) { |
|||
ModalRoute route = ModalRoute.of(context); |
|||
if (route != null) { |
|||
_historyEntry = new LocalHistoryEntry(onRemove: _handleHistoryEntryRemoved); |
|||
route.addLocalHistoryEntry(_historyEntry); |
|||
FocusScope.of(context).setFirstFocus(_focusScopeNode); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void _animationStatusChanged(AnimationStatus status) { |
|||
switch (status) { |
|||
case AnimationStatus.forward: |
|||
_ensureHistoryEntry(); |
|||
break; |
|||
case AnimationStatus.reverse: |
|||
_historyEntry?.remove(); |
|||
_historyEntry = null; |
|||
break; |
|||
case AnimationStatus.dismissed: |
|||
break; |
|||
case AnimationStatus.completed: |
|||
break; |
|||
} |
|||
} |
|||
|
|||
void _handleHistoryEntryRemoved() { |
|||
_historyEntry = null; |
|||
close(); |
|||
} |
|||
|
|||
AnimationController _controller; |
|||
|
|||
|
|||
void _handleDragDown(DragDownDetails details) { |
|||
_controller.stop(); |
|||
_ensureHistoryEntry(); |
|||
} |
|||
|
|||
void _handleDragCancel() { |
|||
if (_controller.isDismissed || _controller.isAnimating) { |
|||
return; |
|||
} |
|||
|
|||
if (_controller.value < 0.5) { |
|||
close(); |
|||
} |
|||
else { |
|||
open(); |
|||
} |
|||
} |
|||
|
|||
public readonly GlobalKey _drawerKey = GlobalKey.key(); |
|||
|
|||
|
|||
float _width { |
|||
get { |
|||
RenderBox box = (RenderBox) _drawerKey.currentContext?.findRenderObject(); |
|||
if (box != null) { |
|||
return box.size.width; |
|||
} |
|||
|
|||
return DrawerUtils._kWidth; |
|||
} |
|||
} |
|||
|
|||
bool _previouslyOpened = false; |
|||
|
|||
void _move(DragUpdateDetails details) { |
|||
float delta = (details.primaryDelta ?? 0) / _width; |
|||
switch (widget.alignment) { |
|||
case DrawerAlignment.start: |
|||
break; |
|||
case DrawerAlignment.end: |
|||
delta = -delta; |
|||
break; |
|||
} |
|||
|
|||
_controller.setValue(_controller.value + delta); |
|||
|
|||
bool opened = _controller.value > 0.5; |
|||
if (opened != _previouslyOpened && widget.drawerCallback != null) { |
|||
widget.drawerCallback(opened); |
|||
} |
|||
|
|||
_previouslyOpened = opened; |
|||
} |
|||
|
|||
void _settle(DragEndDetails details) { |
|||
if (_controller.isDismissed) { |
|||
return; |
|||
} |
|||
|
|||
if (details.velocity.pixelsPerSecond.dx.abs() >= DrawerUtils._kMinFlingVelocity) { |
|||
float visualVelocity = details.velocity.pixelsPerSecond.dx / DrawerUtils._kWidth; |
|||
switch (widget.alignment) { |
|||
case DrawerAlignment.start: |
|||
break; |
|||
case DrawerAlignment.end: |
|||
visualVelocity = -visualVelocity; |
|||
break; |
|||
} |
|||
|
|||
_controller.fling(velocity: visualVelocity); |
|||
} |
|||
else if (_controller.value < 0.5) { |
|||
close(); |
|||
} |
|||
else { |
|||
open(); |
|||
} |
|||
} |
|||
|
|||
public void open() { |
|||
_controller.fling(velocity: 1.0f); |
|||
if (widget.drawerCallback != null) { |
|||
widget.drawerCallback(true); |
|||
} |
|||
} |
|||
|
|||
public void close() { |
|||
_controller.fling(velocity: -1.0f); |
|||
if (widget.drawerCallback != null) { |
|||
widget.drawerCallback(false); |
|||
} |
|||
} |
|||
|
|||
ColorTween _color = new ColorTween(begin: Colors.transparent, end: Colors.black54); |
|||
GlobalKey _gestureDetectorKey = GlobalKey.key(); |
|||
|
|||
Alignment _drawerOuterAlignment { |
|||
get { |
|||
switch (widget.alignment) { |
|||
case DrawerAlignment.start: |
|||
return Alignment.centerLeft; |
|||
case DrawerAlignment.end: |
|||
return Alignment.centerRight; |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
} |
|||
|
|||
Alignment _drawerInnerAlignment { |
|||
get { |
|||
switch (widget.alignment) { |
|||
case DrawerAlignment.start: |
|||
return Alignment.centerRight; |
|||
case DrawerAlignment.end: |
|||
return Alignment.centerLeft; |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
} |
|||
|
|||
Widget _buildDrawer(BuildContext context) { |
|||
bool drawerIsStart = widget.alignment == DrawerAlignment.start; |
|||
EdgeInsets padding = MediaQuery.of(context).padding; |
|||
float dragAreaWidth = drawerIsStart ? padding.left : padding.right; |
|||
|
|||
dragAreaWidth = Mathf.Max(dragAreaWidth, DrawerUtils._kEdgeDragWidth); |
|||
if (_controller.status == AnimationStatus.dismissed) { |
|||
return new Align( |
|||
alignment: _drawerOuterAlignment, |
|||
child: new GestureDetector( |
|||
key: _gestureDetectorKey, |
|||
onHorizontalDragUpdate: _move, |
|||
onHorizontalDragEnd: _settle, |
|||
behavior: HitTestBehavior.translucent, |
|||
dragStartBehavior: widget.dragStartBehavior ?? DragStartBehavior.down, |
|||
child: new Container(width: dragAreaWidth) |
|||
) |
|||
); |
|||
} |
|||
else { |
|||
return new GestureDetector( |
|||
key: _gestureDetectorKey, |
|||
onHorizontalDragDown: _handleDragDown, |
|||
onHorizontalDragUpdate: _move, |
|||
onHorizontalDragEnd: _settle, |
|||
onHorizontalDragCancel: _handleDragCancel, |
|||
dragStartBehavior: widget.dragStartBehavior ?? DragStartBehavior.down, |
|||
child: new RepaintBoundary( |
|||
child: new Stack( |
|||
children: new List<Widget> { |
|||
new GestureDetector( |
|||
onTap: close, |
|||
child: new Container( |
|||
color: _color.evaluate(_controller) |
|||
) |
|||
), |
|||
new Align( |
|||
alignment: _drawerOuterAlignment, |
|||
child: new Align( |
|||
alignment: _drawerInnerAlignment, |
|||
widthFactor: _controller.value, |
|||
child: new RepaintBoundary( |
|||
child: new FocusScope( |
|||
key: _drawerKey, |
|||
node: _focusScopeNode, |
|||
child: widget.child) |
|||
) |
|||
) |
|||
) |
|||
} |
|||
) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new ListTileTheme( |
|||
style: ListTileStyle.drawer, |
|||
child: _buildDrawer(context)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 82ae9917639b741da9df1fe50aeeca67 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
static class DrawerHeaderUtils { |
|||
public const float _kDrawerHeaderHeight = 160.0f + 1.0f; |
|||
} |
|||
|
|||
|
|||
public class DrawerHeader : StatelessWidget { |
|||
public DrawerHeader( |
|||
Key key = null, |
|||
Decoration decoration = null, |
|||
EdgeInsets margin = null, |
|||
EdgeInsets padding = null, |
|||
TimeSpan? duration = null, |
|||
Curve curve = null, |
|||
Widget child = null |
|||
) : base(key: key) { |
|||
D.assert(child != null); |
|||
this.decoration = decoration; |
|||
this.margin = margin ?? EdgeInsets.only(bottom: 8.0f); |
|||
this.padding = padding ?? EdgeInsets.fromLTRB(16.0f, 16.0f, 16.0f, 8.0f); |
|||
this.duration = duration ?? new TimeSpan(0, 0, 0, 0, 250); |
|||
this.curve = curve ?? Curves.fastOutSlowIn; |
|||
this.child = child; |
|||
} |
|||
|
|||
|
|||
public readonly Decoration decoration; |
|||
|
|||
public readonly EdgeInsets padding; |
|||
|
|||
public readonly EdgeInsets margin; |
|||
|
|||
public readonly TimeSpan duration; |
|||
|
|||
public readonly Curve curve; |
|||
|
|||
public readonly Widget child; |
|||
|
|||
|
|||
public override Widget build(BuildContext context) { |
|||
D.assert(MaterialD.debugCheckHasMaterial(context)); |
|||
ThemeData theme = Theme.of(context); |
|||
float statusBarHeight = MediaQuery.of(context).padding.top; |
|||
return new Container( |
|||
height: statusBarHeight + DrawerHeaderUtils._kDrawerHeaderHeight, |
|||
margin: margin, |
|||
decoration: new BoxDecoration( |
|||
border: new Border( |
|||
bottom: Divider.createBorderSide(context) |
|||
) |
|||
), |
|||
child: new AnimatedContainer( |
|||
padding: padding.add(EdgeInsets.only(top: statusBarHeight)), |
|||
decoration: decoration, |
|||
duration: duration, |
|||
curve: curve, |
|||
child: child == null |
|||
? null |
|||
: new DefaultTextStyle( |
|||
style: theme.textTheme.body2, |
|||
child: MediaQuery.removePadding( |
|||
context: context, |
|||
removeTop: true, |
|||
child: child) |
|||
) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b98e2be2eba264e28b3ca08fa93d0f2a |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.service; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class ExpandIcon : StatefulWidget { |
|||
public ExpandIcon( |
|||
Key key = null, |
|||
bool isExpanded = false, |
|||
float size = 24.0f, |
|||
ValueChanged<bool> onPressed = null, |
|||
EdgeInsets padding = null) : base(key: key) { |
|||
this.isExpanded = isExpanded; |
|||
this.size = size; |
|||
this.onPressed = onPressed; |
|||
this.padding = padding ?? EdgeInsets.all(8.0f); |
|||
} |
|||
|
|||
public readonly bool isExpanded; |
|||
|
|||
public readonly float size; |
|||
|
|||
public readonly ValueChanged<bool> onPressed; |
|||
|
|||
public readonly EdgeInsets padding; |
|||
|
|||
public override State createState() { |
|||
return new _ExpandIconState(); |
|||
} |
|||
} |
|||
|
|||
|
|||
public class _ExpandIconState : SingleTickerProviderStateMixin<ExpandIcon> { |
|||
AnimationController _controller; |
|||
Animation<float> _iconTurns; |
|||
|
|||
static readonly Animatable<float> _iconTurnTween = |
|||
new FloatTween(begin: 0.0f, end: 0.5f).chain(new CurveTween(curve: Curves.fastOutSlowIn)); |
|||
|
|||
public override void initState() { |
|||
base.initState(); |
|||
_controller = new AnimationController(duration: ThemeUtils.kThemeAnimationDuration, vsync: this); |
|||
_iconTurns = _controller.drive(_iconTurnTween); |
|||
if (widget.isExpanded) { |
|||
_controller.setValue(Mathf.PI); |
|||
} |
|||
} |
|||
|
|||
public override void dispose() { |
|||
_controller.dispose(); |
|||
base.dispose(); |
|||
} |
|||
|
|||
|
|||
public override void didUpdateWidget(StatefulWidget oldWidget) { |
|||
base.didUpdateWidget(oldWidget); |
|||
ExpandIcon _oldWidget = (ExpandIcon) oldWidget; |
|||
if (widget.isExpanded != _oldWidget.isExpanded) { |
|||
if (widget.isExpanded) { |
|||
_controller.forward(); |
|||
} |
|||
else { |
|||
_controller.reverse(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
void _handlePressed() { |
|||
if (widget.onPressed != null) { |
|||
widget.onPressed(widget.isExpanded); |
|||
} |
|||
} |
|||
|
|||
|
|||
public override Widget build(BuildContext context) { |
|||
D.assert(MaterialD.debugCheckHasMaterial(context)); |
|||
ThemeData theme = Theme.of(context); |
|||
return new IconButton( |
|||
padding: widget.padding, |
|||
color: theme.brightness == Brightness.dark ? Colors.white54 : Colors.black54, |
|||
onPressed: widget.onPressed == null ? (VoidCallback) null : _handlePressed, |
|||
icon: new RotationTransition( |
|||
turns: _iconTurns, |
|||
child: new Icon(Icons.expand_more)) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: e4ab856e0b8e94feabef78ecb303733b |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
static class ExpansionPanelUtils { |
|||
public const float _kPanelHeaderCollapsedHeight = 48.0f; |
|||
public const float _kPanelHeaderExpandedHeight = 64.0f; |
|||
} |
|||
|
|||
|
|||
class _SaltedKey<S, V> : LocalKey { |
|||
public _SaltedKey( |
|||
S salt, |
|||
V value) { |
|||
this.salt = salt; |
|||
this.value = value; |
|||
} |
|||
|
|||
public readonly S salt; |
|||
|
|||
public readonly V value; |
|||
|
|||
public bool Equals(_SaltedKey<S, V> other) { |
|||
if (ReferenceEquals(null, other)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, other)) { |
|||
return true; |
|||
} |
|||
|
|||
return other.salt.Equals(salt) |
|||
&& other.value.Equals(value); |
|||
} |
|||
|
|||
public override bool Equals(object obj) { |
|||
if (ReferenceEquals(null, obj)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, obj)) { |
|||
return true; |
|||
} |
|||
|
|||
if (obj.GetType() != GetType()) { |
|||
return false; |
|||
} |
|||
|
|||
return Equals((_SaltedKey<S, V>) obj); |
|||
} |
|||
|
|||
public static bool operator ==(_SaltedKey<S, V> left, _SaltedKey<S, V> right) { |
|||
return Equals(left, right); |
|||
} |
|||
|
|||
public static bool operator !=(_SaltedKey<S, V> left, _SaltedKey<S, V> right) { |
|||
return !Equals(left, right); |
|||
} |
|||
|
|||
public override int GetHashCode() { |
|||
unchecked { |
|||
var hashCode = salt.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ value.GetHashCode(); |
|||
return hashCode; |
|||
} |
|||
} |
|||
|
|||
public override string ToString() { |
|||
string saltString = salt is string ? "<\'" + salt + "\'>" : "<" + salt + ">"; |
|||
string valueString = value is string ? "<\'" + value + "\'>" : "<" + value + ">"; |
|||
return "[" + saltString + " " + valueString + "]"; |
|||
} |
|||
} |
|||
|
|||
public delegate void ExpansionPanelCallback(int panelIndex, bool isExpanded); |
|||
|
|||
public delegate Widget ExpansionPanelHeaderBuilder(BuildContext context, bool isExpanded); |
|||
|
|||
|
|||
public class ExpansionPanel { |
|||
public ExpansionPanel( |
|||
ExpansionPanelHeaderBuilder headerBuilder = null, |
|||
Widget body = null, |
|||
bool isExpanded = false, |
|||
bool canTapOnHeader = false) { |
|||
D.assert(headerBuilder != null); |
|||
D.assert(body != null); |
|||
this.headerBuilder = headerBuilder; |
|||
this.body = body; |
|||
this.isExpanded = isExpanded; |
|||
this.canTapOnHeader = false; |
|||
} |
|||
|
|||
public readonly ExpansionPanelHeaderBuilder headerBuilder; |
|||
|
|||
public readonly Widget body; |
|||
|
|||
public readonly bool isExpanded; |
|||
|
|||
public readonly bool canTapOnHeader; |
|||
} |
|||
|
|||
|
|||
public class ExpansionPanelRadio : ExpansionPanel { |
|||
public ExpansionPanelRadio( |
|||
object value = null, |
|||
ExpansionPanelHeaderBuilder headerBuilder = null, |
|||
Widget body = null, |
|||
bool canTapOnHeader = false) |
|||
: base(body: body, headerBuilder: headerBuilder, canTapOnHeader: canTapOnHeader) { |
|||
D.assert(headerBuilder != null); |
|||
D.assert(body != null); |
|||
D.assert(value != null); |
|||
this.value = value; |
|||
} |
|||
|
|||
public readonly object value; |
|||
} |
|||
|
|||
public class ExpansionPanelList : StatefulWidget { |
|||
public ExpansionPanelList( |
|||
Key key = null, |
|||
List<ExpansionPanel> children = null, |
|||
ExpansionPanelCallback expansionCallback = null, |
|||
TimeSpan? animationDuration = null) : base(key: key) { |
|||
this.children = children ?? new List<ExpansionPanel>(); |
|||
this.expansionCallback = expansionCallback; |
|||
this.animationDuration = animationDuration ?? Constants.kThemeChangeDuration; |
|||
_allowOnlyOnePanelOpen = false; |
|||
initialOpenPanelValue = null; |
|||
} |
|||
|
|||
ExpansionPanelList( |
|||
Key key = null, |
|||
List<ExpansionPanel> children = null, |
|||
ExpansionPanelCallback expansionCallback = null, |
|||
TimeSpan? animationDuration = null, |
|||
object initialOpenPanelValue = null) : base(key: key) { |
|||
this.children = children ?? new List<ExpansionPanel>(); |
|||
this.expansionCallback = expansionCallback; |
|||
this.animationDuration = animationDuration ?? Constants.kThemeChangeDuration; |
|||
_allowOnlyOnePanelOpen = true; |
|||
this.initialOpenPanelValue = initialOpenPanelValue; |
|||
} |
|||
|
|||
public static ExpansionPanelList radio( |
|||
Key key = null, |
|||
List<ExpansionPanelRadio> children = null, |
|||
ExpansionPanelCallback expansionCallback = null, |
|||
TimeSpan? animationDuration = null, |
|||
object initialOpenPanelValue = null) { |
|||
children = children ?? new List<ExpansionPanelRadio>(); |
|||
var radio = new ExpansionPanelList( |
|||
key: key, |
|||
children: children.Cast<ExpansionPanel>().ToList(), |
|||
expansionCallback: expansionCallback, |
|||
animationDuration: animationDuration, |
|||
initialOpenPanelValue: initialOpenPanelValue |
|||
); |
|||
return radio; |
|||
} |
|||
|
|||
public readonly List<ExpansionPanel> children; |
|||
|
|||
public readonly ExpansionPanelCallback expansionCallback; |
|||
|
|||
public readonly TimeSpan animationDuration; |
|||
|
|||
public readonly bool _allowOnlyOnePanelOpen; |
|||
|
|||
public readonly object initialOpenPanelValue; |
|||
|
|||
public override State createState() { |
|||
return new _ExpansionPanelListState(); |
|||
} |
|||
} |
|||
|
|||
|
|||
public class _ExpansionPanelListState : State<ExpansionPanelList> { |
|||
ExpansionPanelRadio _currentOpenPanel; |
|||
|
|||
public override void initState() { |
|||
base.initState(); |
|||
if (widget._allowOnlyOnePanelOpen) { |
|||
D.assert(_allIdentifierUnique(), () => "All object identifiers are not unique!"); |
|||
foreach (ExpansionPanelRadio child in widget.children) { |
|||
if (widget.initialOpenPanelValue != null && |
|||
child.value == widget.initialOpenPanelValue) { |
|||
_currentOpenPanel = child; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override void didUpdateWidget(StatefulWidget oldWidget) { |
|||
base.didUpdateWidget(oldWidget); |
|||
ExpansionPanelList _oldWidget = (ExpansionPanelList) oldWidget; |
|||
if (widget._allowOnlyOnePanelOpen) { |
|||
D.assert(_allIdentifierUnique(), () => "All object identifiers are not unique!"); |
|||
foreach (ExpansionPanelRadio newChild in widget.children) { |
|||
if (widget.initialOpenPanelValue != null && |
|||
newChild.value == widget.initialOpenPanelValue) { |
|||
_currentOpenPanel = newChild; |
|||
} |
|||
} |
|||
} |
|||
else if (_oldWidget._allowOnlyOnePanelOpen) { |
|||
_currentOpenPanel = null; |
|||
} |
|||
} |
|||
|
|||
bool _allIdentifierUnique() { |
|||
Dictionary<object, bool> identifierMap = new Dictionary<object, bool>(); |
|||
foreach (ExpansionPanelRadio child in widget.children) { |
|||
identifierMap[child.value] = true; |
|||
} |
|||
|
|||
return identifierMap.Count == widget.children.Count; |
|||
} |
|||
|
|||
bool _isChildExpanded(int index) { |
|||
if (widget._allowOnlyOnePanelOpen) { |
|||
ExpansionPanelRadio radioWidget = (ExpansionPanelRadio) widget.children[index]; |
|||
return _currentOpenPanel?.value == radioWidget.value; |
|||
} |
|||
|
|||
return widget.children[index].isExpanded; |
|||
} |
|||
|
|||
void _handlePressed(bool isExpanded, int index) { |
|||
if (widget.expansionCallback != null) { |
|||
widget.expansionCallback(index, isExpanded); |
|||
} |
|||
|
|||
if (widget._allowOnlyOnePanelOpen) { |
|||
ExpansionPanelRadio pressedChild = (ExpansionPanelRadio) widget.children[index]; |
|||
|
|||
for (int childIndex = 0; childIndex < widget.children.Count; childIndex++) { |
|||
ExpansionPanelRadio child = (ExpansionPanelRadio) widget.children[childIndex]; |
|||
if (widget.expansionCallback != null && childIndex != index && |
|||
child.value == _currentOpenPanel?.value) { |
|||
widget.expansionCallback(childIndex, false); |
|||
} |
|||
} |
|||
|
|||
_currentOpenPanel = isExpanded ? null : pressedChild; |
|||
} |
|||
|
|||
setState(() => { }); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
List<MergeableMaterialItem> items = new List<MergeableMaterialItem>(); |
|||
EdgeInsets kExpandedEdgeInsets = EdgeInsets.symmetric( |
|||
vertical: ExpansionPanelUtils._kPanelHeaderExpandedHeight - |
|||
ExpansionPanelUtils._kPanelHeaderCollapsedHeight); |
|||
|
|||
for (int index = 0; index < widget.children.Count; index++) { |
|||
int expandIndex = index; |
|||
if (_isChildExpanded(index) && index != 0 && !_isChildExpanded(index - 1)) { |
|||
items.Add(new MaterialGap( |
|||
key: new _SaltedKey<BuildContext, int>(context, index * 2 - 1))); |
|||
} |
|||
|
|||
ExpansionPanel child = widget.children[index]; |
|||
Widget headerWidget = child.headerBuilder( |
|||
context, |
|||
_isChildExpanded(index) |
|||
); |
|||
Row header = new Row( |
|||
children: new List<Widget> { |
|||
new Expanded( |
|||
child: new AnimatedContainer( |
|||
duration: widget.animationDuration, |
|||
curve: Curves.fastOutSlowIn, |
|||
margin: _isChildExpanded(index) ? kExpandedEdgeInsets : EdgeInsets.zero, |
|||
child: new ConstrainedBox( |
|||
constraints: new BoxConstraints( |
|||
minHeight: ExpansionPanelUtils._kPanelHeaderCollapsedHeight), |
|||
child: headerWidget |
|||
) |
|||
) |
|||
), |
|||
new Container( |
|||
margin: EdgeInsets.fromLTRB(0, 0, 8, 0), |
|||
child: new ExpandIcon( |
|||
isExpanded: _isChildExpanded(index), |
|||
padding: EdgeInsets.all(16.0f), |
|||
onPressed: !child.canTapOnHeader |
|||
? (ValueChanged<bool>) ((bool isExpanded) => { |
|||
_handlePressed(isExpanded, expandIndex); |
|||
}) |
|||
: null |
|||
) |
|||
) |
|||
} |
|||
); |
|||
|
|||
items.Add(new MaterialSlice( |
|||
key: new _SaltedKey<BuildContext, int>(context, index * 2), |
|||
child: new Column( |
|||
children: new List<Widget> { |
|||
child.canTapOnHeader |
|||
? (Widget) new InkWell( |
|||
onTap: () => |
|||
_handlePressed(_isChildExpanded(expandIndex), expandIndex), |
|||
child: header |
|||
) |
|||
: header, |
|||
new AnimatedCrossFade( |
|||
firstChild: new Container(height: 0.0f), |
|||
secondChild: child.body, |
|||
firstCurve: new Interval(0.0f, 0.6f, curve: Curves.fastOutSlowIn), |
|||
secondCurve: new Interval(0.4f, 1.0f, curve: Curves.fastOutSlowIn), |
|||
sizeCurve: Curves.fastOutSlowIn, |
|||
crossFadeState: _isChildExpanded(index) |
|||
? CrossFadeState.showSecond |
|||
: CrossFadeState.showFirst, |
|||
duration: widget.animationDuration |
|||
) |
|||
} |
|||
) |
|||
) |
|||
); |
|||
|
|||
if (_isChildExpanded(index) && index != widget.children.Count - 1) { |
|||
items.Add(new MaterialGap( |
|||
key: new _SaltedKey<BuildContext, int>(context, index * 2 + 1))); |
|||
} |
|||
} |
|||
|
|||
return new MergeableMaterial( |
|||
hasDividers: true, |
|||
children: items); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: dcaf0d752807146868207f41db41ccb1 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
static class ExpansionTileUtils { |
|||
public static readonly TimeSpan _kExpand = new TimeSpan(0, 0, 0, 0, 200); |
|||
} |
|||
|
|||
public class ExpansionTile : StatefulWidget { |
|||
public ExpansionTile( |
|||
Key key = null, |
|||
Widget leading = null, |
|||
Widget title = null, |
|||
Color backgroundColor = null, |
|||
ValueChanged<bool> onExpansionChanged = null, |
|||
List<Widget> children = null, |
|||
Widget trailing = null, |
|||
bool initiallyExpanded = false |
|||
) : base(key: key) { |
|||
D.assert(title != null); |
|||
this.leading = leading; |
|||
this.title = title; |
|||
this.backgroundColor = backgroundColor; |
|||
this.onExpansionChanged = onExpansionChanged; |
|||
this.children = children ?? new List<Widget>(); |
|||
this.trailing = trailing; |
|||
this.initiallyExpanded = initiallyExpanded; |
|||
} |
|||
|
|||
public readonly Widget leading; |
|||
|
|||
public readonly Widget title; |
|||
|
|||
public readonly ValueChanged<bool> onExpansionChanged; |
|||
|
|||
public readonly List<Widget> children; |
|||
|
|||
public readonly Color backgroundColor; |
|||
|
|||
public readonly Widget trailing; |
|||
|
|||
public readonly bool initiallyExpanded; |
|||
|
|||
public override State createState() { |
|||
return new _ExpansionTileState(); |
|||
} |
|||
} |
|||
|
|||
public class _ExpansionTileState : SingleTickerProviderStateMixin<ExpansionTile> { |
|||
static readonly Animatable<float> _easeOutTween = new CurveTween(curve: Curves.easeOut); |
|||
static readonly Animatable<float> _easeInTween = new CurveTween(curve: Curves.easeIn); |
|||
static readonly Animatable<float> _halfTween = new FloatTween(begin: 0.0f, end: 0.5f); |
|||
|
|||
readonly ColorTween _borderColorTween = new ColorTween(); |
|||
readonly ColorTween _headerColorTween = new ColorTween(); |
|||
readonly ColorTween _iconColorTween = new ColorTween(); |
|||
readonly ColorTween _backgroundColorTween = new ColorTween(); |
|||
|
|||
AnimationController _controller; |
|||
Animation<float> _iconTurns; |
|||
Animation<float> _heightFactor; |
|||
Animation<Color> _borderColor; |
|||
Animation<Color> _headerColor; |
|||
Animation<Color> _iconColor; |
|||
Animation<Color> _backgroundColor; |
|||
|
|||
bool _isExpanded = false; |
|||
|
|||
public override void initState() { |
|||
base.initState(); |
|||
_controller = new AnimationController(duration: ExpansionTileUtils._kExpand, vsync: this); |
|||
_heightFactor = _controller.drive(_easeInTween); |
|||
_iconTurns = _controller.drive(_halfTween.chain(_easeInTween)); |
|||
_borderColor = _controller.drive(_borderColorTween.chain(_easeOutTween)); |
|||
_headerColor = _controller.drive(_headerColorTween.chain(_easeInTween)); |
|||
_iconColor = _controller.drive(_iconColorTween.chain(_easeInTween)); |
|||
_backgroundColor = _controller.drive(_backgroundColorTween.chain(_easeOutTween)); |
|||
|
|||
_isExpanded = PageStorage.of(context)?.readState(context) == null |
|||
? widget.initiallyExpanded |
|||
: (bool) PageStorage.of(context)?.readState(context); |
|||
|
|||
if (_isExpanded) { |
|||
_controller.setValue(1.0f); |
|||
} |
|||
} |
|||
|
|||
public override void dispose() { |
|||
_controller.dispose(); |
|||
base.dispose(); |
|||
} |
|||
|
|||
void _handleTap() { |
|||
setState(() => { |
|||
_isExpanded = !_isExpanded; |
|||
if (_isExpanded) { |
|||
_controller.forward(); |
|||
} |
|||
else { |
|||
_controller.reverse().Then(() => { |
|||
if (!mounted) { |
|||
return; |
|||
} |
|||
|
|||
setState(() => { }); |
|||
}); |
|||
} |
|||
|
|||
PageStorage.of(context)?.writeState(context, _isExpanded); |
|||
}); |
|||
if (widget.onExpansionChanged != null) { |
|||
widget.onExpansionChanged(_isExpanded); |
|||
} |
|||
} |
|||
|
|||
Widget _buildChildren(BuildContext context, Widget child) { |
|||
Color borderSideColor = _borderColor.value ?? Colors.transparent; |
|||
|
|||
return new Container( |
|||
decoration: new BoxDecoration( |
|||
color: _backgroundColor.value ?? Colors.transparent, |
|||
border: new Border( |
|||
top: new BorderSide(color: borderSideColor), |
|||
bottom: new BorderSide(color: borderSideColor))), |
|||
child: new Column( |
|||
mainAxisSize: MainAxisSize.min, |
|||
children: new List<Widget> { |
|||
ListTileTheme.merge( |
|||
iconColor: _iconColor.value, |
|||
textColor: _headerColor.value, |
|||
child: new ListTile( |
|||
onTap: _handleTap, |
|||
leading: widget.leading, |
|||
title: widget.title, |
|||
trailing: widget.trailing ?? new RotationTransition( |
|||
turns: _iconTurns, |
|||
child: new Icon(Icons.expand_more) |
|||
) |
|||
) |
|||
), |
|||
new ClipRect( |
|||
child: new Align( |
|||
heightFactor: _heightFactor.value, |
|||
child: child) |
|||
) |
|||
} |
|||
) |
|||
); |
|||
} |
|||
|
|||
public override void didChangeDependencies() { |
|||
ThemeData theme = Theme.of(context); |
|||
_borderColorTween.end = theme.dividerColor; |
|||
_headerColorTween.begin = theme.textTheme.subhead.color; |
|||
_headerColorTween.end = theme.accentColor; |
|||
_iconColorTween.begin = theme.unselectedWidgetColor; |
|||
_iconColorTween.end = theme.accentColor; |
|||
_backgroundColorTween.end = widget.backgroundColor; |
|||
base.didChangeDependencies(); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
bool closed = !_isExpanded && _controller.isDismissed; |
|||
return new AnimatedBuilder( |
|||
animation: _controller.view, |
|||
builder: _buildChildren, |
|||
child: closed ? null : new Column(children: widget.children)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: dd2974d0b3bb843e782324d1b493fe24 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.service; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class FlatButton : MaterialButton { |
|||
public FlatButton( |
|||
Key key = null, |
|||
VoidCallback onPressed = null, |
|||
ValueChanged<bool> onHighlightChanged = null, |
|||
ButtonTextTheme? textTheme = null, |
|||
Color textColor = null, |
|||
Color disabledTextColor = null, |
|||
Color color = null, |
|||
Color disabledColor = null, |
|||
Color highlightColor = null, |
|||
Color splashColor = null, |
|||
Brightness? colorBrightness = null, |
|||
EdgeInsets padding = null, |
|||
ShapeBorder shape = null, |
|||
Clip? clipBehavior = Clip.none, |
|||
MaterialTapTargetSize? materialTapTargetSize = null, |
|||
Widget child = null) : base( |
|||
key: key, |
|||
onPressed: onPressed, |
|||
onHighlightChanged: onHighlightChanged, |
|||
textTheme: textTheme, |
|||
textColor: textColor, |
|||
disabledTextColor: disabledTextColor, |
|||
color: color, |
|||
disabledColor: disabledColor, |
|||
highlightColor: highlightColor, |
|||
splashColor: splashColor, |
|||
colorBrightness: colorBrightness, |
|||
padding: padding, |
|||
shape: shape, |
|||
clipBehavior: clipBehavior, |
|||
materialTapTargetSize: materialTapTargetSize, |
|||
child: child) { |
|||
} |
|||
|
|||
public static FlatButton icon( |
|||
Key key = null, |
|||
VoidCallback onPressed = null, |
|||
ValueChanged<bool> onHighlightChanged = null, |
|||
ButtonTextTheme? textTheme = null, |
|||
Color textColor = null, |
|||
Color disabledTextColor = null, |
|||
Color color = null, |
|||
Color disabledColor = null, |
|||
Color highlightColor = null, |
|||
Color splashColor = null, |
|||
Brightness? colorBrightness = null, |
|||
EdgeInsets padding = null, |
|||
ShapeBorder shape = null, |
|||
Clip? clipBehavior = null, |
|||
MaterialTapTargetSize? materialTapTargetSize = null, |
|||
Widget icon = null, |
|||
Widget label = null) { |
|||
D.assert(icon != null); |
|||
D.assert(label != null); |
|||
|
|||
return new _FlatButtonWithIcon( |
|||
key: key, |
|||
onPressed: onPressed, |
|||
onHighlightChanged: onHighlightChanged, |
|||
textTheme: textTheme, |
|||
textColor: textColor, |
|||
disabledTextColor: disabledTextColor, |
|||
color: color, |
|||
disabledColor: disabledColor, |
|||
highlightColor: highlightColor, |
|||
splashColor: splashColor, |
|||
colorBrightness: colorBrightness, |
|||
padding: padding, |
|||
shape: shape, |
|||
clipBehavior: clipBehavior, |
|||
materialTapTargetSize: materialTapTargetSize, |
|||
icon: icon, |
|||
label: label |
|||
); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
ThemeData theme = Theme.of(context); |
|||
ButtonThemeData buttonTheme = ButtonTheme.of(context); |
|||
|
|||
return new RawMaterialButton( |
|||
onPressed: onPressed, |
|||
onHighlightChanged: onHighlightChanged, |
|||
clipBehavior: clipBehavior ?? Clip.none, |
|||
fillColor: buttonTheme.getFillColor(this), |
|||
textStyle: theme.textTheme.button.copyWith(color: buttonTheme.getTextColor(this)), |
|||
highlightColor: buttonTheme.getHighlightColor(this), |
|||
splashColor: buttonTheme.getSplashColor(this), |
|||
elevation: buttonTheme.getElevation(this), |
|||
highlightElevation: buttonTheme.getHighlightElevation(this), |
|||
disabledElevation: buttonTheme.getDisabledElevation(this), |
|||
padding: buttonTheme.getPadding(this), |
|||
constraints: buttonTheme.getConstraints(this), |
|||
shape: buttonTheme.getShape(this), |
|||
animationDuration: buttonTheme.getAnimationDuration(this), |
|||
materialTapTargetSize: buttonTheme.getMaterialTapTargetSize(this), |
|||
child: child |
|||
); |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
properties.add(new ObjectFlagProperty<VoidCallback>("onPressed", onPressed, ifNull: "disabled")); |
|||
properties.add(new DiagnosticsProperty<ButtonTextTheme?>("textTheme", textTheme, defaultValue: null)); |
|||
properties.add(new DiagnosticsProperty<Color>("textColor", textColor, defaultValue: null)); |
|||
properties.add(new DiagnosticsProperty<Color>("disabledTextColor", disabledTextColor, |
|||
defaultValue: null)); |
|||
properties.add(new DiagnosticsProperty<Color>("color", color, defaultValue: null)); |
|||
properties.add(new DiagnosticsProperty<Color>("disabledColor", disabledColor, defaultValue: null)); |
|||
properties.add(new DiagnosticsProperty<Color>("highlightColor", highlightColor, defaultValue: null)); |
|||
properties.add(new DiagnosticsProperty<Color>("splashColor", splashColor, defaultValue: null)); |
|||
properties.add(new DiagnosticsProperty<Brightness?>("colorBrightness", colorBrightness, |
|||
defaultValue: null)); |
|||
properties.add(new DiagnosticsProperty<EdgeInsets>("padding", padding, defaultValue: null)); |
|||
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", shape, defaultValue: null)); |
|||
properties.add(new DiagnosticsProperty<MaterialTapTargetSize?>("materialTapTargetSize", |
|||
materialTapTargetSize, defaultValue: null)); |
|||
} |
|||
} |
|||
|
|||
class _FlatButtonWithIcon : FlatButton, MaterialButtonWithIconMixin { |
|||
public _FlatButtonWithIcon( |
|||
Key key = null, |
|||
VoidCallback onPressed = null, |
|||
ValueChanged<bool> onHighlightChanged = null, |
|||
ButtonTextTheme? textTheme = null, |
|||
Color textColor = null, |
|||
Color disabledTextColor = null, |
|||
Color color = null, |
|||
Color disabledColor = null, |
|||
Color highlightColor = null, |
|||
Color splashColor = null, |
|||
Brightness? colorBrightness = null, |
|||
EdgeInsets padding = null, |
|||
ShapeBorder shape = null, |
|||
Clip? clipBehavior = null, |
|||
MaterialTapTargetSize? materialTapTargetSize = null, |
|||
Widget icon = null, |
|||
Widget label = null) : base( |
|||
key: key, |
|||
onPressed: onPressed, |
|||
onHighlightChanged: onHighlightChanged, |
|||
textTheme: textTheme, |
|||
textColor: textColor, |
|||
disabledTextColor: disabledTextColor, |
|||
color: color, |
|||
disabledColor: disabledColor, |
|||
highlightColor: highlightColor, |
|||
splashColor: splashColor, |
|||
colorBrightness: colorBrightness, |
|||
padding: padding, |
|||
shape: shape, |
|||
clipBehavior: clipBehavior, |
|||
materialTapTargetSize: materialTapTargetSize, |
|||
child: new Row( |
|||
mainAxisSize: MainAxisSize.min, |
|||
children: new List<Widget> { |
|||
icon, |
|||
new SizedBox(width: 8.0f), |
|||
label |
|||
} |
|||
)) { |
|||
D.assert(icon != null); |
|||
D.assert(label != null); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ad54f63ca420e42518aead08e1b27526 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class GridTile : StatelessWidget { |
|||
public GridTile( |
|||
Key key = null, |
|||
Widget header = null, |
|||
Widget footer = null, |
|||
Widget child = null) : base(key: key) { |
|||
D.assert(child != null); |
|||
this.header = header; |
|||
this.footer = footer; |
|||
this.child = child; |
|||
} |
|||
|
|||
public readonly Widget header; |
|||
|
|||
public readonly Widget footer; |
|||
|
|||
public readonly Widget child; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
if (header == null && footer == null) { |
|||
return child; |
|||
} |
|||
|
|||
List<Widget> children = new List<Widget> { |
|||
Positioned.fill( |
|||
child: child) |
|||
}; |
|||
if (header != null) { |
|||
children.Add(new Positioned( |
|||
top: 0.0f, |
|||
left: 0.0f, |
|||
right: 0.0f, |
|||
child: header)); |
|||
} |
|||
|
|||
if (footer != null) { |
|||
children.Add(new Positioned( |
|||
left: 0.0f, |
|||
bottom: 0.0f, |
|||
right: 0.0f, |
|||
child: footer)); |
|||
} |
|||
|
|||
return new Stack( |
|||
children: children); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8613dcab63f30445c80e76df18408797 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
using Color = Unity.UIWidgets.ui.Color; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
static class IconButtonUtils { |
|||
public const float _kMinButtonSize = 48.0f; |
|||
} |
|||
|
|||
|
|||
public class IconButton : StatelessWidget { |
|||
public IconButton( |
|||
Key key = null, |
|||
float iconSize = 24.0f, |
|||
EdgeInsets padding = null, |
|||
Alignment alignment = null, |
|||
Widget icon = null, |
|||
Color color = null, |
|||
Color highlightColor = null, |
|||
Color splashColor = null, |
|||
Color disableColor = null, |
|||
VoidCallback onPressed = null, |
|||
string tooltip = null) : base(key: key) { |
|||
D.assert(icon != null); |
|||
|
|||
this.iconSize = iconSize; |
|||
this.padding = padding ?? EdgeInsets.all(8.0f); |
|||
this.alignment = alignment ?? Alignment.center; |
|||
this.icon = icon; |
|||
this.color = color; |
|||
this.highlightColor = highlightColor; |
|||
this.splashColor = splashColor; |
|||
disabledColor = disableColor; |
|||
this.onPressed = onPressed; |
|||
this.tooltip = tooltip; |
|||
} |
|||
|
|||
public readonly float iconSize; |
|||
|
|||
public readonly EdgeInsets padding; |
|||
|
|||
public readonly Alignment alignment; |
|||
|
|||
public readonly Widget icon; |
|||
|
|||
public readonly Color color; |
|||
|
|||
public readonly Color splashColor; |
|||
|
|||
public readonly Color highlightColor; |
|||
|
|||
public readonly Color disabledColor; |
|||
|
|||
public readonly VoidCallback onPressed; |
|||
|
|||
public readonly string tooltip; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
D.assert(MaterialD.debugCheckHasMaterial(context)); |
|||
Color currentColor; |
|||
if (onPressed != null) { |
|||
currentColor = color; |
|||
} |
|||
else { |
|||
currentColor = disabledColor ?? Theme.of(context).disabledColor; |
|||
} |
|||
|
|||
Widget result = new ConstrainedBox( |
|||
constraints: new BoxConstraints(minWidth: IconButtonUtils._kMinButtonSize, |
|||
minHeight: IconButtonUtils._kMinButtonSize), |
|||
child: new Padding( |
|||
padding: padding, |
|||
child: new SizedBox( |
|||
height: iconSize, |
|||
width: iconSize, |
|||
child: new Align( |
|||
alignment: alignment, |
|||
child: IconTheme.merge( |
|||
data: new IconThemeData( |
|||
size: iconSize, |
|||
color: currentColor), |
|||
child: icon) |
|||
) |
|||
) |
|||
) |
|||
); |
|||
|
|||
if (tooltip != null) { |
|||
result = new Tooltip( |
|||
message: tooltip, |
|||
child: result); |
|||
} |
|||
|
|||
return new InkResponse( |
|||
onTap: () => { |
|||
if (onPressed != null) { |
|||
onPressed(); |
|||
} |
|||
}, |
|||
child: result, |
|||
highlightColor: highlightColor ?? Theme.of(context).highlightColor, |
|||
splashColor: splashColor ?? Theme.of(context).splashColor, |
|||
radius: Mathf.Max( |
|||
Material.defaultSplashRadius, |
|||
(iconSize + Mathf.Min(padding.horizontal, padding.vertical)) * 0.7f) |
|||
); |
|||
} |
|||
|
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
properties.add(new DiagnosticsProperty<Widget>("icon", icon, showName: false)); |
|||
properties.add(new ObjectFlagProperty<VoidCallback>("onPressed", onPressed, ifNull: "disabled")); |
|||
properties.add(new StringProperty("tooltip", tooltip, defaultValue: null, quoted: false)); |
|||
} |
|||
} |
|||
} |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue