浏览代码

add gallery widgets

/zgh-devtools
xingweizhu 4 年前
当前提交
4c412bce
共有 21 个文件被更改,包括 1957 次插入1 次删除
  1. 2
      com.unity.uiwidgets/Runtime/painting/edge_insets.cs
  2. 3
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery.meta
  3. 70
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/about.cs
  4. 3
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/about.cs.meta
  5. 411
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/backdrop.cs
  6. 3
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/backdrop.cs.meta
  7. 195
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demos.cs
  8. 3
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demos.cs.meta
  9. 222
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/home.cs
  10. 3
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/home.cs.meta
  11. 48
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/icons.cs
  12. 3
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/icons.cs.meta
  13. 631
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/options.cs
  14. 3
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/options.cs.meta
  15. 158
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/scales.cs
  16. 3
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/scales.cs.meta
  17. 95
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/themes.cs
  18. 3
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/themes.cs.meta
  19. 96
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/updater.cs
  20. 3
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/updater.cs.meta

2
com.unity.uiwidgets/Runtime/painting/edge_insets.cs


}
}
class EdgeInsetsDirectional : EdgeInsetsGeometry {
public class EdgeInsetsDirectional : EdgeInsetsGeometry {
public EdgeInsetsDirectional(float start, float top, float end, float bottom) {
this.start = start;
this.end = end;

3
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery.meta


fileFormatVersion: 2
guid: 20b07a92c4c64919aa3adf9322758a65
timeCreated: 1612322595

70
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/about.cs


using System.Collections.Generic;
using System.Diagnostics;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery.gallery
{
public static class GalleryAboutUtils
{
public static void showGalleryAboutDialog(BuildContext context)
{
ThemeData themeData = Theme.of(context);
TextStyle aboutTextStyle = themeData.textTheme.bodyText1;
TextStyle linkStyle = themeData.textTheme.bodyText1.copyWith(color: themeData.accentColor);
material_.showAboutDialog(
context: context,
applicationVersion: "January 2021",
children: new List<Widget>
{
new Padding(
padding: EdgeInsets.only(top: 24.0f),
child: new RichText(
text: new TextSpan(
children: new List<InlineSpan>
{
new TextSpan(
style: aboutTextStyle,
text: "uiwidgets is an open-source project to help developers " +
"build high-performance, high-fidelity, mobile apps for multiple platforms using " +
"Unity Editor" +
"from a single codebase. This design lab is a playground " +
"and showcase of Flutter's many widgets, behaviors, " +
"animations, layouts, and more. Learn more about Flutter at "
),
new _LinkTextSpan(
style: linkStyle,
url: "https://github.com/Unity-Technologies/com.unity.uiwidgets",
text: "uiWidgets github repo"
),
new TextSpan(
style: aboutTextStyle,
text: "."
)
}
)
)
)
}
);
}
}
public class _LinkTextSpan : TextSpan
{
private static void launch(string url)
{
Process.Start(url);
}
public _LinkTextSpan(TextStyle style = null, string url = null, string text = null) : base(
style: style,
text: text ?? url,
recognizer: new TapGestureRecognizer {onTap = () => { launch(url); }}
)
{
}
}
}

3
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/about.cs.meta


fileFormatVersion: 2
guid: d167035ecc19482a9586a95d0a562503
timeCreated: 1612322610

411
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/backdrop.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
namespace UIWidgetsGallery.gallery
{
public static class GalleryBackdropUtils
{
public const float _kFrontHeadingHeight = 32.0f; // front layer beveled rectangle
public const float _kFrontClosedHeight = 92.0f; // front layer height when closed
public const float _kBackAppBarHeight = 56.0f; // back layer (options) appbar height
public static readonly Animatable<BorderRadius> _kFrontHeadingBevelRadius = new BorderRadiusTween(
begin: BorderRadius.only(
topLeft: Radius.circular(12.0f),
topRight: Radius.circular(12.0f)
),
end: BorderRadius.only(
topLeft: Radius.circular(_kFrontHeadingHeight),
topRight: Radius.circular(_kFrontHeadingHeight)
)
);
}
internal class _TappableWhileStatusIs : StatefulWidget
{
public _TappableWhileStatusIs(
AnimationStatus status,
Key key = null,
AnimationController controller = null,
Widget child = null
) : base(key: key)
{
this.controller = controller;
this.status = status;
this.child = child;
}
public readonly AnimationController controller;
public readonly AnimationStatus status;
public readonly Widget child;
public override State createState()
{
return new _TappableWhileStatusIsState();
}
}
internal class _TappableWhileStatusIsState : State<_TappableWhileStatusIs>
{
private bool _active;
public override void initState()
{
base.initState();
this.widget.controller.addStatusListener(this._handleStatusChange);
this._active = this.widget.controller.status == this.widget.status;
}
public override void dispose()
{
this.widget.controller.removeStatusListener(this._handleStatusChange);
base.dispose();
}
private void _handleStatusChange(AnimationStatus status)
{
bool value = this.widget.controller.status == this.widget.status;
if (this._active != value)
this.setState(() => { this._active = value; });
}
public override Widget build(BuildContext context)
{
Widget child = new AbsorbPointer(
absorbing: !this._active,
child: this.widget.child
);
if (!this._active)
child = new FocusScope(
canRequestFocus: false,
debugLabel: "_TappableWhileStatusIs",
child: child
);
return child;
}
}
internal class _CrossFadeTransition : AnimatedWidget
{
public _CrossFadeTransition(
Key key = null,
Alignment alignment = null,
Animation<float> progress = null,
Widget child0 = null,
Widget child1 = null
) : base(key: key, listenable: progress)
{
alignment = alignment ?? Alignment.center;
this.alignment = alignment;
this.child0 = child0;
this.child1 = child1;
}
public readonly Alignment alignment;
public readonly Widget child0;
public readonly Widget child1;
protected override Widget build(BuildContext context)
{
Animation<float> progress = this.listenable as Animation<float>;
float opacity1 = new CurvedAnimation(
parent: new ReverseAnimation(progress),
curve: new Interval(0.5f, 1.0f)
).value;
float opacity2 = new CurvedAnimation(
parent: progress,
curve: new Interval(0.5f, 1.0f)
).value;
return new Stack(
alignment: this.alignment,
children: new List<Widget>
{
new Opacity(
opacity: opacity1,
child: this.child1
),
new Opacity(
opacity: opacity2,
child: this.child0
)
}
);
}
}
internal class _BackAppBar : StatelessWidget
{
public _BackAppBar(
Key key = null,
Widget leading = null,
Widget title = null,
Widget trailing = null
) : base(key: key)
{
leading = leading ?? new SizedBox(width: 56.0f);
D.assert(title != null);
this.leading = leading;
this.title = title;
this.trailing = trailing;
}
public readonly Widget leading;
public readonly Widget title;
public readonly Widget trailing;
public override Widget build(BuildContext context)
{
ThemeData theme = Theme.of(context);
List<Widget> children = new List<Widget>
{
new Container(
alignment: Alignment.center,
width: 56.0f,
child: this.leading
),
new Expanded(
child: this.title
)
};
if (this.trailing != null)
children.Add(new Container(
alignment: Alignment.center,
width: 56.0f,
child: this.trailing
));
return IconTheme.merge(
data: theme.primaryIconTheme,
child: new DefaultTextStyle(
style: theme.primaryTextTheme.headline6,
child: new SizedBox(
height: GalleryBackdropUtils._kBackAppBarHeight,
child: new Row(
children: children
)
)
)
);
}
}
internal class Backdrop : StatefulWidget
{
public Backdrop(
Widget frontAction = null,
Widget frontTitle = null,
Widget frontLayer = null,
Widget frontHeading = null,
Widget backTitle = null,
Widget backLayer = null
)
{
this.frontAction = frontAction;
this.frontTitle = frontTitle;
this.frontLayer = frontLayer;
this.frontHeading = frontHeading;
this.backTitle = backTitle;
this.backLayer = backLayer;
}
public readonly Widget frontAction;
public readonly Widget frontTitle;
public readonly Widget frontLayer;
public readonly Widget frontHeading;
public readonly Widget backTitle;
public readonly Widget backLayer;
public override State createState()
{
return new _BackdropState();
}
}
internal class _BackdropState : SingleTickerProviderStateMixin<Backdrop>
{
private GlobalKey _backdropKey = GlobalKey.key(debugLabel: "Backdrop");
private AnimationController _controller;
private Animation<float> _frontOpacity;
private static readonly Animatable<float> _frontOpacityTween = new Tween<float>(begin: 0.2f, end: 1.0f)
.chain(new CurveTween(curve: new Interval(0.0f, 0.4f, curve: Curves.easeInOut)));
public override void initState()
{
base.initState();
this._controller = new AnimationController(
duration: new TimeSpan(0, 0, 0, 0, 300),
value: 1.0f,
vsync: this
);
this._frontOpacity = this._controller.drive(_frontOpacityTween);
}
public override void dispose()
{
this._controller.dispose();
base.dispose();
}
private float _backdropHeight
{
get
{
// Warning: this can be safely called from the event handlers but it may
// not be called at build time.
RenderBox renderBox = this._backdropKey.currentContext.findRenderObject() as RenderBox;
return Mathf.Max(0.0f,
renderBox.size.height - GalleryBackdropUtils._kBackAppBarHeight -
GalleryBackdropUtils._kFrontClosedHeight);
}
}
private void _handleDragUpdate(DragUpdateDetails details)
{
this._controller.setValue(this._controller.value - details.primaryDelta.Value / this._backdropHeight);
}
private void _handleDragEnd(DragEndDetails details)
{
if (this._controller.isAnimating || this._controller.status == AnimationStatus.completed)
return;
float flingVelocity = details.velocity.pixelsPerSecond.dy / this._backdropHeight;
if (flingVelocity < 0.0)
this._controller.fling(velocity: Mathf.Max(2.0f, -flingVelocity));
else if (flingVelocity > 0.0)
this._controller.fling(velocity: Mathf.Min(-2.0f, -flingVelocity));
else
this._controller.fling(velocity: this._controller.value < 0.5 ? -2.0f : 2.0f);
}
private void _toggleFrontLayer()
{
AnimationStatus status = this._controller.status;
bool isOpen = status == AnimationStatus.completed || status == AnimationStatus.forward;
this._controller.fling(velocity: isOpen ? -2.0f : 2.0f);
}
private Widget _buildStack(BuildContext context, BoxConstraints constraints)
{
Animation<RelativeRect> frontRelativeRect = this._controller.drive(new RelativeRectTween(
begin: RelativeRect.fromLTRB(0.0f,
constraints.biggest.height - GalleryBackdropUtils._kFrontClosedHeight, 0.0f, 0.0f),
end: RelativeRect.fromLTRB(0.0f, GalleryBackdropUtils._kBackAppBarHeight, 0.0f, 0.0f)
));
var children = new List<Widget>
{
new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: new List<Widget>
{
new _BackAppBar(
leading: this.widget.frontAction,
title: new _CrossFadeTransition(
progress: this._controller,
alignment: Alignment.center,
//alignment: AlignmentDirectional.centerStart,
child0: this.widget.frontTitle,
child1: this.widget.backTitle
),
trailing: new IconButton(
onPressed: this._toggleFrontLayer,
tooltip: "Toggle options page",
icon: new AnimatedIcon(
icon: AnimatedIcons.close_menu,
progress: this._controller
)
)
),
new Expanded(
child: new _TappableWhileStatusIs(
AnimationStatus.dismissed,
controller: this._controller,
child: new Visibility(
child: this.widget.backLayer,
visible: this._controller.status != AnimationStatus.completed,
maintainState: true
)
)
)
}
),
// Front layer
new PositionedTransition(
rect: frontRelativeRect,
child: new AnimatedBuilder(
animation: this._controller,
builder: (BuildContext subContext, Widget child) =>
{
return new PhysicalShape(
elevation: 12.0f,
color: Theme.of(subContext).canvasColor,
clipper: new ShapeBorderClipper(
shape: new BeveledRectangleBorder(
borderRadius: GalleryBackdropUtils._kFrontHeadingBevelRadius.transform(
this._controller.value)
)
),
clipBehavior: Clip.antiAlias,
child: child
);
},
child: new _TappableWhileStatusIs(
AnimationStatus.completed,
controller: this._controller,
child: new FadeTransition(
opacity: this._frontOpacity,
child: this.widget.frontLayer
)
)
)
)
};
if (this.widget.frontHeading != null)
children.Add(new PositionedTransition(
rect: frontRelativeRect,
child: new Container(
alignment: Alignment.topLeft,
child: new GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: this._toggleFrontLayer,
onVerticalDragUpdate: this._handleDragUpdate,
onVerticalDragEnd: this._handleDragEnd,
child: this.widget.frontHeading
)
)
));
return new Stack(
key: this._backdropKey,
children: children
);
}
public override Widget build(BuildContext context)
{
return new LayoutBuilder(builder: this._buildStack);
}
}
}

3
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/backdrop.cs.meta


fileFormatVersion: 2
guid: a1683ac7e52d43c2b016d6f38ee988ad
timeCreated: 1612334782

195
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demos.cs


using System;
using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery.gallery
{
public class GalleryDemoCategory
{
public GalleryDemoCategory(
string name,
IconData icon)
{
this.name = name;
this.icon = icon;
}
public readonly string name;
public readonly IconData icon;
public bool Equals(GalleryDemoCategory other)
{
if (ReferenceEquals(this, other))
{
return true;
}
if (ReferenceEquals(other, null))
{
return false;
}
return this.icon.Equals(other.icon) && this.name == other.name;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(this, obj))
{
return true;
}
if (ReferenceEquals(obj, null))
{
return false;
}
if (obj.GetType() != GetType())
{
return false;
}
return Equals((GalleryDemoCategory)obj);
}
public static bool operator==(GalleryDemoCategory left, GalleryDemoCategory right)
{
return Equals(left, right);
}
public static bool operator !=(GalleryDemoCategory left, GalleryDemoCategory right)
{
return !Equals(left, right);
}
public override int GetHashCode() {
unchecked {
return ((icon?.GetHashCode() ?? 0) * 397) ^ (name?.GetHashCode() ?? 0);
}
}
public override string ToString()
{
return $"{GetType()}{name}";
}
public static readonly GalleryDemoCategory _kDemos = new GalleryDemoCategory(
name: "Studies",
icon: GalleryIcons.animation
);
public static readonly GalleryDemoCategory _kStyle = new GalleryDemoCategory(
name: "Style",
icon: GalleryIcons.custom_typography
);
public static readonly GalleryDemoCategory _kMaterialComponents = new GalleryDemoCategory(
name: "Material",
icon: GalleryIcons.category_mdc
);
public static readonly GalleryDemoCategory _kCupertinoComponents = new GalleryDemoCategory(
name: "Cupertino",
icon: GalleryIcons.phone_iphone
);
public static readonly GalleryDemoCategory _kMedia = new GalleryDemoCategory(
name: "Media",
icon: GalleryIcons.drive_video
);
}
class GalleryDemo {
public GalleryDemo(
string title = null,
IconData icon = null,
string subtitle = null,
GalleryDemoCategory category = null,
string routeName = null,
string documentationUrl = null,
WidgetBuilder buildRoute = null
)
{
D.assert(title != null);
D.assert(category != null);
D.assert(routeName != null);
D.assert(buildRoute != null);
this.title = title;
this.icon = icon;
this.subtitle = subtitle;
this.category = category;
this.routeName = routeName;
this.documentationUrl = documentationUrl;
this.buildRoute = buildRoute;
}
public readonly string title;
public readonly IconData icon;
public readonly string subtitle;
public readonly GalleryDemoCategory category;
public readonly string routeName;
public readonly WidgetBuilder buildRoute;
public readonly string documentationUrl;
public override string ToString() {
return $"{GetType()}({title} {routeName})";
}
public static List<GalleryDemo> _buildGalleryDemos()
{
List<GalleryDemo> galleryDemos = new List<GalleryDemo>
{
};
return galleryDemos;
}
public static readonly List<GalleryDemo> kAllGalleryDemos = _buildGalleryDemos();
public static readonly List<GalleryDemoCategory> kAllGalleryDemoCategories =
kAllGalleryDemos.Select<GalleryDemo, GalleryDemoCategory>((GalleryDemo demo) => demo.category).ToList();
static Dictionary<GalleryDemoCategory, List<GalleryDemo>> _generateCategoryToDemos()
{
Dictionary<GalleryDemoCategory, List<GalleryDemo>> result =
new Dictionary<GalleryDemoCategory, List<GalleryDemo>>();
foreach (var category in kAllGalleryDemoCategories)
{
result.Add(category, kAllGalleryDemos.Where((GalleryDemo demo) =>
{
return demo.category == category;
}).ToList());
}
return result;
}
public static readonly Dictionary<GalleryDemoCategory, List<GalleryDemo>> kGalleryCategoryToDemos =
_generateCategoryToDemos();
static Dictionary<string, string> _generateDemoDocumentationUrls()
{
Dictionary<string, string> result = new Dictionary<string, string>();
foreach (var demo in kAllGalleryDemos)
{
if (demo.documentationUrl != null)
{
result.Add(demo.routeName, demo.documentationUrl);
}
}
return result;
}
public static readonly Dictionary<string, string> kDemoDocumentationUrl = _generateDemoDocumentationUrls();
}
}

3
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demos.cs.meta


fileFormatVersion: 2
guid: beaf8ef32d5a4e4b847b0626276b30ca
timeCreated: 1612337523

222
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/home.cs


using System;
using System.Collections.Generic;
using System.Linq;
using uiwidgets;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
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 UIWidgetsGallery.gallery
{
public static class GalleryHomeUtils
{
public static readonly string _kGalleryAssetsPackage = "uiwdigets_gallery_assets";
public static readonly Color _kFlutterBlue = new Color(0xFF003D75);
public const float _kDemoItemHeight = 64.0f;
public static readonly TimeSpan _kFrontLayerSwitchDuration = new TimeSpan(0, 0, 0, 0, 300);
}
class _CategoryItem : StatelessWidget {
public _CategoryItem(
Key key = null,
GalleryDemoCategory category = null,
VoidCallback onTap = null
) : base (key: key)
{
this.category = category;
this.onTap = onTap;
}
public readonly GalleryDemoCategory category;
public readonly VoidCallback onTap;
public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
bool isDark = theme.brightness == Brightness.dark;
// This repaint boundary prevents the entire _CategoriesPage from being
// repainted when the button's ink splash animates.
return new RepaintBoundary(
child: new RawMaterialButton(
padding: EdgeInsets.zero,
hoverColor: theme.primaryColor.withOpacity(0.05f),
splashColor: theme.primaryColor.withOpacity(0.12f),
highlightColor: Colors.transparent,
onPressed: onTap,
child: new Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: new List<Widget>{
new Padding(
padding: EdgeInsets.all(6.0f),
child: new Icon(
category.icon,
size: 60.0f,
color: isDark ? Colors.white : GalleryHomeUtils._kFlutterBlue
)
),
new SizedBox(height: 10.0f),
new Container(
height: 48.0f,
alignment: Alignment.center,
child: new Text(
category.name,
textAlign: TextAlign.center,
style: theme.textTheme.subtitle1.copyWith(
color: isDark ? Colors.white : GalleryHomeUtils._kFlutterBlue
)
)
)
}
)
)
);
}
}
class _CategoriesPage : StatelessWidget
{
public _CategoriesPage(
Key key = null,
IEnumerable<GalleryDemoCategory> categories = null,
ValueChanged<GalleryDemoCategory> onCategoryTap = null
) : base(key: key)
{
this.categories = categories;
this.onCategoryTap = onCategoryTap;
}
public readonly IEnumerable<GalleryDemoCategory> categories;
public readonly ValueChanged<GalleryDemoCategory> onCategoryTap;
public override Widget build(BuildContext context)
{
float aspectRatio = 160.0f / 180.0f;
List<GalleryDemoCategory> categoriesList = categories.ToList();
int columnCount = (MediaQuery.of(context).orientation == Orientation.portrait) ? 2 : 3;
return new SingleChildScrollView(
key: PageStorageKey<String>.key("categories"),
child: new LayoutBuilder(
builder: (BuildContext subContext, BoxConstraints constraints) =>
{
float columnWidth = constraints.biggest.width / columnCount;
float rowHeight = Mathf.Min(225.0f, columnWidth * aspectRatio);
int rowCount = (categories.Count() + columnCount - 1) / columnCount;
var children = new List<Widget>();
for (var i = 0; i < rowCount; i++)
{
var rowIndex = i;
int columnCountForRow = rowIndex == rowCount - 1
? categories.Count() - columnCount * Mathf.Max(0, rowCount - 1)
: columnCount;
var subChildren = new List<Widget>();
for (var j = 0; j < columnCountForRow; j++)
{
var columnIndex = j;
int index = rowIndex * columnCount + columnIndex;
GalleryDemoCategory category = categoriesList[index];
subChildren.Add(new SizedBox(width: columnWidth,
height: rowHeight,
child: new _CategoryItem(
category: category,
onTap: () => { onCategoryTap(category); }
)
));
}
children.Add(new Row(
children: subChildren
));
}
return new RepaintBoundary(
child: new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: children
)
);
}));
}
}
class _DemoItem : StatelessWidget {
public _DemoItem(Key key = null, GalleryDemo demo = null) : base(key: key)
{
this.demo = demo;
}
public readonly GalleryDemo demo;
void _launchDemo(BuildContext context) {
if (demo.routeName != null) {
Navigator.pushNamed(context, demo.routeName);
}
}
@override
Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context);
final bool isDark = theme.brightness == Brightness.dark;
final double textScaleFactor = MediaQuery.textScaleFactorOf(context);
return RawMaterialButton(
padding: EdgeInsets.zero,
splashColor: theme.primaryColor.withOpacity(0.12),
highlightColor: Colors.transparent,
onPressed: () {
_launchDemo(context);
},
child: Container(
constraints: BoxConstraints(minHeight: _kDemoItemHeight * textScaleFactor),
child: Row(
children: <Widget>[
Container(
width: 56.0,
height: 56.0,
alignment: Alignment.center,
child: Icon(
demo.icon,
size: 24.0,
color: isDark ? Colors.white : _kFlutterBlue,
),
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text(
demo.title,
style: theme.textTheme.subtitle1.copyWith(
color: isDark ? Colors.white : const Color(0xFF202124),
),
),
if (demo.subtitle != null)
Text(
demo.subtitle,
style: theme.textTheme.bodyText2.copyWith(
color: isDark ? Colors.white : const Color(0xFF60646B)
),
),
],
),
),
const SizedBox(width: 44.0),
],
),
),
);
}
}
}

3
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/home.cs.meta


fileFormatVersion: 2
guid: 5c8e2b6d71b743648d57a549e2b0c62e
timeCreated: 1612338820

48
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/icons.cs


using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery.gallery
{
public static class GalleryIcons
{
public static readonly IconData tooltip = new IconData(0xe900, fontFamily: "GalleryIcons");
public static readonly IconData text_fields_alt = new IconData(0xe901, fontFamily: "GalleryIcons");
public static readonly IconData tabs = new IconData(0xe902, fontFamily: "GalleryIcons");
public static readonly IconData switches = new IconData(0xe903, fontFamily: "GalleryIcons");
public static readonly IconData sliders = new IconData(0xe904, fontFamily: "GalleryIcons");
public static readonly IconData shrine = new IconData(0xe905, fontFamily: "GalleryIcons");
public static readonly IconData sentiment_very_satisfied = new IconData(0xe906, fontFamily: "GalleryIcons");
public static readonly IconData refresh = new IconData(0xe907, fontFamily: "GalleryIcons");
public static readonly IconData progress_activity = new IconData(0xe908, fontFamily: "GalleryIcons");
public static readonly IconData phone_iphone = new IconData(0xe909, fontFamily: "GalleryIcons");
public static readonly IconData page_control = new IconData(0xe90a, fontFamily: "GalleryIcons");
public static readonly IconData more_vert = new IconData(0xe90b, fontFamily: "GalleryIcons");
public static readonly IconData menu = new IconData(0xe90c, fontFamily: "GalleryIcons");
public static readonly IconData list_alt = new IconData(0xe90d, fontFamily: "GalleryIcons");
public static readonly IconData grid_on = new IconData(0xe90e, fontFamily: "GalleryIcons");
public static readonly IconData expand_all = new IconData(0xe90f, fontFamily: "GalleryIcons");
public static readonly IconData events = new IconData(0xe910, fontFamily: "GalleryIcons");
public static readonly IconData drive_video = new IconData(0xe911, fontFamily: "GalleryIcons");
public static readonly IconData dialogs = new IconData(0xe912, fontFamily: "GalleryIcons");
public static readonly IconData data_table = new IconData(0xe913, fontFamily: "GalleryIcons");
public static readonly IconData custom_typography = new IconData(0xe914, fontFamily: "GalleryIcons");
public static readonly IconData colors = new IconData(0xe915, fontFamily: "GalleryIcons");
public static readonly IconData chips = new IconData(0xe916, fontFamily: "GalleryIcons");
public static readonly IconData check_box = new IconData(0xe917, fontFamily: "GalleryIcons");
public static readonly IconData cards = new IconData(0xe918, fontFamily: "GalleryIcons");
public static readonly IconData buttons = new IconData(0xe919, fontFamily: "GalleryIcons");
public static readonly IconData bottom_sheets = new IconData(0xe91a, fontFamily: "GalleryIcons");
public static readonly IconData bottom_navigation = new IconData(0xe91b, fontFamily: "GalleryIcons");
public static readonly IconData animation = new IconData(0xe91c, fontFamily: "GalleryIcons");
public static readonly IconData account_box = new IconData(0xe91d, fontFamily: "GalleryIcons");
public static readonly IconData snackbar = new IconData(0xe91e, fontFamily: "GalleryIcons");
public static readonly IconData category_mdc = new IconData(0xe91f, fontFamily: "GalleryIcons");
public static readonly IconData cupertino_progress = new IconData(0xe920, fontFamily: "GalleryIcons");
public static readonly IconData cupertino_pull_to_refresh = new IconData(0xe921, fontFamily: "GalleryIcons");
public static readonly IconData cupertino_switch = new IconData(0xe922, fontFamily: "GalleryIcons");
public static readonly IconData generic_buttons = new IconData(0xe923, fontFamily: "GalleryIcons");
public static readonly IconData backdrop = new IconData(0xe924, fontFamily: "GalleryIcons");
public static readonly IconData bottom_app_bar = new IconData(0xe925, fontFamily: "GalleryIcons");
public static readonly IconData bottom_sheet_persistent = new IconData(0xe926, fontFamily: "GalleryIcons");
public static readonly IconData lists_leave_behind = new IconData(0xe927, fontFamily: "GalleryIcons");
}
}

3
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/icons.cs.meta


fileFormatVersion: 2
guid: 77d0b3e255db46828d85f61b587bcb43
timeCreated: 1612324774

631
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/options.cs


using System;
using System.Collections.Generic;
using System.Linq;
using uiwidgets;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
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 UIWidgetsGallery.gallery
{
public static class GalleryOptionUtils
{
public const float _kItemHeight = 48.0f;
//TODO: uncomment this when fixes on EdgeInsetsDirectional lands
//public static readonly EdgeInsetsDirectional _kItemPadding = EdgeInsetsDirectional.only(start: 56.0f);
public static readonly EdgeInsets _kItemPadding = EdgeInsets.only(left: 56.0f);
}
public class GalleryOptions : IEquatable<GalleryOptions>
{
public GalleryOptions(
ThemeMode? themeMode = null,
GalleryTextScaleValue textScaleFactor = null,
GalleryVisualDensityValue visualDensity = null,
TextDirection? textDirection = null,
float timeDilation = 1.0f,
RuntimePlatform? platform = null,
bool showOffscreenLayersCheckerboard = false,
bool showRasterCacheImagesCheckerboard = false,
bool showPerformanceOverlay = false
)
{
this.themeMode = themeMode;
this.textScaleFactor = textScaleFactor;
this.visualDensity = visualDensity;
this.textDirection = textDirection;
this.timeDilation = timeDilation;
this.platform = platform;
this.showOffscreenLayersCheckerboard = showOffscreenLayersCheckerboard;
this.showRasterCacheImagesCheckerboard = showRasterCacheImagesCheckerboard;
this.showPerformanceOverlay = showPerformanceOverlay;
}
public readonly ThemeMode? themeMode;
public readonly GalleryTextScaleValue textScaleFactor;
public readonly GalleryVisualDensityValue visualDensity;
public readonly TextDirection? textDirection;
public readonly float timeDilation;
public readonly RuntimePlatform? platform;
public readonly bool showPerformanceOverlay;
public readonly bool showRasterCacheImagesCheckerboard;
public readonly bool showOffscreenLayersCheckerboard;
internal GalleryOptions copyWith(
ThemeMode? themeMode = null,
GalleryTextScaleValue textScaleFactor = null,
GalleryVisualDensityValue visualDensity = null,
TextDirection? textDirection = null,
float? timeDilation = null,
RuntimePlatform? platform = null,
bool? showPerformanceOverlay = null,
bool? showRasterCacheImagesCheckerboard = null,
bool? showOffscreenLayersCheckerboard = null
)
{
return new GalleryOptions(
themeMode: themeMode ?? this.themeMode,
textScaleFactor: textScaleFactor ?? this.textScaleFactor,
visualDensity: visualDensity ?? this.visualDensity,
textDirection: textDirection ?? this.textDirection,
timeDilation: timeDilation ?? this.timeDilation,
platform: platform ?? this.platform,
showPerformanceOverlay: showPerformanceOverlay ?? this.showPerformanceOverlay,
showOffscreenLayersCheckerboard:
showOffscreenLayersCheckerboard ?? this.showOffscreenLayersCheckerboard,
showRasterCacheImagesCheckerboard: showRasterCacheImagesCheckerboard ??
this.showRasterCacheImagesCheckerboard
);
}
public bool Equals(GalleryOptions other)
{
if (ReferenceEquals(this, other)) return true;
if (ReferenceEquals(other, null)) return false;
return this.themeMode.Equals(other.themeMode)
&& this.textScaleFactor == other.textScaleFactor
&& this.visualDensity == other.visualDensity
&& this.textDirection == other.textDirection
&& this.platform == other.platform
&& this.showPerformanceOverlay == other.showPerformanceOverlay
&& this.showRasterCacheImagesCheckerboard == other.showRasterCacheImagesCheckerboard
&& this.showOffscreenLayersCheckerboard == other.showOffscreenLayersCheckerboard;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(this, obj)) return true;
if (ReferenceEquals(obj, null)) return false;
if (obj.GetType() != this.GetType()) return false;
return this.Equals((GalleryOptions) obj);
}
public static bool operator ==(GalleryOptions left, GalleryOptions right)
{
return Equals(left, right);
}
public static bool operator !=(GalleryOptions left, GalleryOptions right)
{
return !Equals(left, right);
}
public override int GetHashCode()
{
unchecked
{
var hashcode = this.themeMode?.GetHashCode() ?? 0;
hashcode = (hashcode * 397) ^ this.textScaleFactor.GetHashCode();
hashcode = (hashcode * 397) ^ this.visualDensity.GetHashCode();
hashcode = (hashcode * 397) ^ (this.textDirection?.GetHashCode() ?? 0);
hashcode = (hashcode * 397) ^ this.timeDilation.GetHashCode();
hashcode = (hashcode * 397) ^ (this.platform?.GetHashCode() ?? 0);
hashcode = (hashcode * 397) ^ this.showPerformanceOverlay.GetHashCode();
hashcode = (hashcode * 397) ^ this.showRasterCacheImagesCheckerboard.GetHashCode();
hashcode = (hashcode * 397) ^ this.showOffscreenLayersCheckerboard.GetHashCode();
return hashcode;
}
}
public override string ToString()
{
return $"{this.GetType()}{this.themeMode}";
}
}
internal class _OptionsItem : StatelessWidget
{
public _OptionsItem(Key key = null, Widget child = null) : base(key: key)
{
this.child = child;
}
public readonly Widget child;
public override Widget build(BuildContext context)
{
float textScaleFactor = MediaQuery.textScaleFactorOf(context);
return new Container(
constraints: new BoxConstraints(minHeight: GalleryOptionUtils._kItemHeight * textScaleFactor),
padding: GalleryOptionUtils._kItemPadding,
alignment: AlignmentDirectional.centerStart,
child: new DefaultTextStyle(
style: DefaultTextStyle.of(context).style,
maxLines: 2,
overflow: TextOverflow.fade,
child: new IconTheme(
data: Theme.of(context).primaryIconTheme,
child: this.child
)
)
);
}
}
internal class _BooleanItem : StatelessWidget
{
public _BooleanItem(string title, bool value, ValueChanged<bool?> onChanged, Key switchKey = null)
{
this.title = title;
this.value = value;
this.onChanged = onChanged;
this.switchKey = switchKey;
}
public readonly string title;
public readonly bool value;
public readonly ValueChanged<bool?> onChanged;
public readonly Key switchKey;
public override Widget build(BuildContext context)
{
bool isDark = Theme.of(context).brightness == Brightness.dark;
return new _OptionsItem(
child: new Row(
children: new List<Widget>
{
new Expanded(child: new Text(this.title)),
new Switch(
key: this.switchKey,
value: this.value,
onChanged: this.onChanged,
activeColor: new Color(0xFF39CEFD),
activeTrackColor: isDark ? Colors.white30 : Colors.black26
)
}
)
);
}
}
internal class _ActionItem : StatelessWidget
{
public _ActionItem(string text, VoidCallback onTap)
{
this.text = text;
this.onTap = onTap;
}
public readonly string text;
public readonly VoidCallback onTap;
public override Widget build(BuildContext context)
{
return new _OptionsItem(
child: new _FlatButton(
onPressed: this.onTap,
child: new Text(this.text)
)
);
}
}
internal class _FlatButton : StatelessWidget
{
public _FlatButton(Key key = null, VoidCallback onPressed = null, Widget child = null) : base(key: key)
{
this.child = child;
this.onPressed = onPressed;
}
public readonly VoidCallback onPressed;
public readonly Widget child;
public override Widget build(BuildContext context)
{
return new FlatButton(
padding: EdgeInsets.zero,
onPressed: this.onPressed,
child: new DefaultTextStyle(
style: Theme.of(context).primaryTextTheme.subtitle1,
child: this.child
)
);
}
}
internal class _Heading : StatelessWidget
{
public _Heading(string text)
{
this.text = text;
}
public readonly string text;
public override Widget build(BuildContext context)
{
ThemeData theme = Theme.of(context);
return new _OptionsItem(
child: new DefaultTextStyle(
style: theme.textTheme.headline6.copyWith(
color: theme.colorScheme.onPrimary,
fontWeight: FontWeight.w700
),
child: new Text(this.text)
)
);
}
}
internal class _ThemeModeItem : StatelessWidget
{
public _ThemeModeItem(GalleryOptions options, ValueChanged<GalleryOptions> onOptionsChanged)
{
this.options = options;
this.onOptionsChanged = onOptionsChanged;
}
public readonly GalleryOptions options;
public readonly ValueChanged<GalleryOptions> onOptionsChanged;
public static readonly Dictionary<ThemeMode, string> modeLabels = new Dictionary<ThemeMode, string>
{
{ThemeMode.system, "System Default"},
{ThemeMode.light, "Light"},
{ThemeMode.dark, "Dark"},
};
public override Widget build(BuildContext context)
{
return new _OptionsItem(
child: new Row(
children: new List<Widget>
{
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget>
{
new Text("Theme"),
new Text(
modeLabels[this.options.themeMode.Value],
style: Theme.of(context).primaryTextTheme.bodyText2
)
}
)
),
new PopupMenuButton<ThemeMode>(
//TODO: uncomment this when fixes on EdgeInsetsDirectional lands
//padding: const EdgeInsetsDirectional.only(end: 16.0),
padding: EdgeInsets.only(right: 16.0f),
icon: new Icon(Icons.arrow_drop_down),
initialValue: this.options.themeMode.Value,
itemBuilder: (BuildContext subContext) =>
{
return modeLabels.Keys.Select<ThemeMode, PopupMenuEntry<ThemeMode>>((ThemeMode mode) =>
{
return new PopupMenuItem<ThemeMode>(
value: mode,
child: new Text(modeLabels[mode])
);
}).ToList();
},
onSelected: (ThemeMode mode) =>
{
this.onOptionsChanged(this.options.copyWith(themeMode: mode)
);
}
)
}
)
);
}
}
internal class _TextScaleFactorItem : StatelessWidget
{
public _TextScaleFactorItem(GalleryOptions options, ValueChanged<GalleryOptions> onOptionsChanged)
{
this.options = options;
this.onOptionsChanged = onOptionsChanged;
}
public readonly GalleryOptions options;
public readonly ValueChanged<GalleryOptions> onOptionsChanged;
public override Widget build(BuildContext context)
{
return new _OptionsItem(
child: new Row(
children: new List<Widget>
{
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget>
{
new Text("Text size"),
new Text(this.options.textScaleFactor.label,
style: Theme.of(context).primaryTextTheme.bodyText2
)
}
)
),
new PopupMenuButton<GalleryTextScaleValue>(
//TODO: uncomment this when fixes on EdgeInsetsDirectional lands
//padding: EdgeInsetsDirectional.only(end: 16.0f),
padding: EdgeInsets.only(right: 16.0f),
icon: new Icon(Icons.arrow_drop_down),
itemBuilder: (BuildContext subContext) =>
{
return GalleryTextScaleValue.kAllGalleryTextScaleValues
.Select<GalleryTextScaleValue, PopupMenuEntry<GalleryTextScaleValue>>(
(GalleryTextScaleValue scaleValue) =>
{
return new PopupMenuItem<GalleryTextScaleValue>(
value: scaleValue,
child: new Text(scaleValue.label)
);
}).ToList();
},
onSelected: (GalleryTextScaleValue scaleValue) =>
{
this.onOptionsChanged(this.options.copyWith(textScaleFactor: scaleValue)
);
}
)
}
)
);
}
}
internal class _VisualDensityItem : StatelessWidget
{
public _VisualDensityItem(GalleryOptions options, ValueChanged<GalleryOptions> onOptionsChanged)
{
this.options = options;
this.onOptionsChanged = onOptionsChanged;
}
public readonly GalleryOptions options;
public readonly ValueChanged<GalleryOptions> onOptionsChanged;
public override Widget build(BuildContext context)
{
return new _OptionsItem(
child: new Row(
children: new List<Widget>
{
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget>
{
new Text("Visual density"),
new Text(this.options.visualDensity.label,
style: Theme.of(context).primaryTextTheme.bodyText2
)
}
)
),
new PopupMenuButton<GalleryVisualDensityValue>(
//TODO: uncomment this when fixes on EdgeInsetsDirectional lands
//padding: EdgeInsetsDirectional.only(end: 16.0f),
padding: EdgeInsets.only(right: 16.0f),
icon: new Icon(Icons.arrow_drop_down),
itemBuilder: (BuildContext subContext) =>
{
return GalleryVisualDensityValue.kAllGalleryVisualDensityValues
.Select<GalleryVisualDensityValue, PopupMenuEntry<GalleryVisualDensityValue>>(
(GalleryVisualDensityValue densityValue) =>
{
return new PopupMenuItem<GalleryVisualDensityValue>(
value: densityValue,
child: new Text(densityValue.label)
);
}).ToList();
},
onSelected: (GalleryVisualDensityValue densityValue) =>
{
this.onOptionsChanged(this.options.copyWith(visualDensity: densityValue)
);
}
)
}
)
);
}
}
internal class _TextDirectionItem : StatelessWidget
{
public _TextDirectionItem(GalleryOptions options, ValueChanged<GalleryOptions> onOptionsChanged)
{
this.options = options;
this.onOptionsChanged = onOptionsChanged;
}
public readonly GalleryOptions options;
public readonly ValueChanged<GalleryOptions> onOptionsChanged;
public override Widget build(BuildContext context)
{
return new _BooleanItem(
"Force RTL", this.options.textDirection == TextDirection.rtl,
(bool? value) =>
{
this.onOptionsChanged(this.options.copyWith(
textDirection: value == true ? TextDirection.rtl : TextDirection.ltr
)
);
},
switchKey: Key.key("text_direction")
);
}
}
internal class _TimeDilationItem : StatelessWidget
{
public _TimeDilationItem(GalleryOptions options, ValueChanged<GalleryOptions> onOptionsChanged)
{
this.options = options;
this.onOptionsChanged = onOptionsChanged;
}
public readonly GalleryOptions options;
public readonly ValueChanged<GalleryOptions> onOptionsChanged;
public override Widget build(BuildContext context)
{
return new _BooleanItem(
"Slow motion", this.options.timeDilation != 1.0f,
(bool? value) =>
{
this.onOptionsChanged(this.options.copyWith(
timeDilation: value == true ? 20.0f : 1.0f
)
);
},
switchKey: Key.key("slow_motion")
);
}
}
internal class _PlatformItem : StatelessWidget
{
public _PlatformItem(GalleryOptions options, ValueChanged<GalleryOptions> onOptionsChanged)
{
this.options = options;
this.onOptionsChanged = onOptionsChanged;
}
public readonly GalleryOptions options;
public readonly ValueChanged<GalleryOptions> onOptionsChanged;
private string _platformLabel(RuntimePlatform? platform)
{
return platform.ToString();
}
private static List<RuntimePlatform> _platforms = new List<RuntimePlatform>
{RuntimePlatform.Android, RuntimePlatform.IPhonePlayer, RuntimePlatform.WindowsPlayer};
public override Widget build(BuildContext context)
{
return new _OptionsItem(
child: new Row(
children: new List<Widget>
{
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget>
{
new Text("Platform mechanics"),
new Text(this._platformLabel(this.options.platform),
style: Theme.of(context).primaryTextTheme.bodyText2
)
}
)
),
new PopupMenuButton<RuntimePlatform>(
//TODO: uncomment this when fixes on EdgeInsetsDirectional lands
//padding: EdgeInsetsDirectional.only(end: 16.0f),
padding: EdgeInsets.only(right: 16.0f),
icon: new Icon(Icons.arrow_drop_down),
itemBuilder: (BuildContext subContext) =>
{
return _platforms.Select<RuntimePlatform, PopupMenuEntry<RuntimePlatform>>(
(RuntimePlatform platform) =>
{
return new PopupMenuItem<RuntimePlatform>(
value: platform,
child: new Text(this._platformLabel(platform))
);
}).ToList();
},
onSelected: (RuntimePlatform platform) =>
{
this.onOptionsChanged(this.options.copyWith(platform: platform)
);
}
)
}
)
);
}
}
internal class GalleryOptionsPage : StatelessWidget
{
public GalleryOptionsPage(
Key key = null,
GalleryOptions options = null,
ValueChanged<GalleryOptions> onOptionsChanged = null,
VoidCallback onSendFeedback = null
) : base(key: key)
{
this.options = options;
this.onOptionsChanged = onOptionsChanged;
this.onSendFeedback = onSendFeedback;
}
public readonly GalleryOptions options;
public readonly ValueChanged<GalleryOptions> onOptionsChanged;
public readonly VoidCallback onSendFeedback;
public override Widget build(BuildContext context)
{
ThemeData theme = Theme.of(context);
return new DefaultTextStyle(
style: theme.primaryTextTheme.subtitle1,
child: new ListView(
padding: EdgeInsets.only(bottom: 124.0f),
children: new List<Widget>
{
new _Heading("Display"),
new _ThemeModeItem(this.options, this.onOptionsChanged),
new _TextScaleFactorItem(this.options, this.onOptionsChanged),
new _VisualDensityItem(this.options, this.onOptionsChanged),
new _TextDirectionItem(this.options, this.onOptionsChanged),
new _TimeDilationItem(this.options, this.onOptionsChanged),
new Divider(),
new _PlatformItem(this.options, this.onOptionsChanged),
new Divider(),
new _Heading("Flutter gallery"),
new _ActionItem("About Flutter Gallery",
() => { GalleryAboutUtils.showGalleryAboutDialog(context); }),
new _ActionItem("Send feedback", this.onSendFeedback)
}
)
);
}
}
}

3
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/options.cs.meta


fileFormatVersion: 2
guid: 73fb5821ecc441269db224976d575666
timeCreated: 1612324913

158
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/scales.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.material;
namespace UIWidgetsGallery.gallery
{
public class GalleryTextScaleValue : IEquatable<GalleryTextScaleValue>
{
public GalleryTextScaleValue(float? scale, string label)
{
this.scale = scale;
this.label = label;
}
public readonly float? scale;
public readonly string label;
public bool Equals(GalleryTextScaleValue other)
{
if (ReferenceEquals(this, other))
{
return true;
}
if (ReferenceEquals(other, null))
{
return false;
}
return this.scale.Equals(other.scale) && this.label == other.label;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(this, obj))
{
return true;
}
if (ReferenceEquals(obj, null))
{
return false;
}
if (obj.GetType() != GetType())
{
return false;
}
return Equals((GalleryTextScaleValue)obj);
}
public static bool operator==(GalleryTextScaleValue left, GalleryTextScaleValue right)
{
return Equals(left, right);
}
public static bool operator !=(GalleryTextScaleValue left, GalleryTextScaleValue right)
{
return !Equals(left, right);
}
public override int GetHashCode() {
unchecked {
return ((label?.GetHashCode() ?? 0) * 397) ^ (scale?.GetHashCode() ?? 0);
}
}
public override string ToString()
{
return $"{GetType()}{label}";
}
public static readonly List<GalleryTextScaleValue> kAllGalleryTextScaleValues = new List<GalleryTextScaleValue>{
new GalleryTextScaleValue(null, "System Default"),
new GalleryTextScaleValue(0.8f, "Small"),
new GalleryTextScaleValue(1.0f, "Normal"),
new GalleryTextScaleValue(1.3f, "Large"),
new GalleryTextScaleValue(2.0f, "Huge"),
};
}
public class GalleryVisualDensityValue : IEquatable<GalleryVisualDensityValue>
{
public GalleryVisualDensityValue(VisualDensity visualDensity, string label)
{
this.visualDensity = visualDensity;
this.label = label;
}
public readonly VisualDensity visualDensity;
public readonly string label;
public bool Equals(GalleryVisualDensityValue other)
{
if (ReferenceEquals(this, other))
{
return true;
}
if (ReferenceEquals(other, null))
{
return false;
}
return this.visualDensity.Equals(other.visualDensity) && this.label == other.label;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(this, obj))
{
return true;
}
if (ReferenceEquals(obj, null))
{
return false;
}
if (obj.GetType() != GetType())
{
return false;
}
return Equals((GalleryVisualDensityValue)obj);
}
public static bool operator==(GalleryVisualDensityValue left, GalleryVisualDensityValue right)
{
return Equals(left, right);
}
public static bool operator !=(GalleryVisualDensityValue left, GalleryVisualDensityValue right)
{
return !Equals(left, right);
}
public override int GetHashCode() {
unchecked {
return ((label?.GetHashCode() ?? 0) * 397) ^ (visualDensity?.GetHashCode() ?? 0);
}
}
public override string ToString()
{
return $"{GetType()}{label}";
}
public static readonly List<GalleryVisualDensityValue> kAllGalleryVisualDensityValues = new List<GalleryVisualDensityValue>{
new GalleryVisualDensityValue(new VisualDensity(), "System Default"),
new GalleryVisualDensityValue(VisualDensity.comfortable, "Comfortable"),
new GalleryVisualDensityValue(VisualDensity.compact, "Compact"),
new GalleryVisualDensityValue(new VisualDensity(horizontal: -3, vertical: -3), "Very Compact")
};
}
}

3
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/scales.cs.meta


fileFormatVersion: 2
guid: 536d205536f347459208349c7fb5220c
timeCreated: 1612324936

95
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/themes.cs


using uiwidgets;
using Unity.UIWidgets.material;
using Unity.UIWidgets.ui;
namespace UIWidgetsGallery.gallery
{
public static class GalleyThemes
{
public static readonly ThemeData kLightGalleryTheme = _buildLightTheme();
public static readonly ThemeData kDarkGalleryTheme = _buildDarkTheme();
private static string _defaultGalleryFontFamily = "";
private static TextTheme _buildTextTheme(TextTheme baseTheme)
{
if (_defaultGalleryFontFamily != "")
return baseTheme.copyWith(
headline6: baseTheme.headline6.copyWith(
fontFamily: _defaultGalleryFontFamily
)
);
return baseTheme;
}
private static ThemeData _buildDarkTheme()
{
Color primaryColor = new Color(0xFF0175c2);
Color secondaryColor = new Color(0xFF13B9FD);
ColorScheme colorScheme = ColorScheme.dark().copyWith(
primary: primaryColor,
secondary: secondaryColor
);
ThemeData baseTheme = new ThemeData(
brightness: Brightness.dark,
accentColorBrightness: Brightness.dark,
primaryColor: primaryColor,
primaryColorDark: new Color(0xFF0050a0),
primaryColorLight: secondaryColor,
buttonColor: primaryColor,
indicatorColor: Colors.white,
toggleableActiveColor: new Color(0xFF6997DF),
accentColor: secondaryColor,
canvasColor: new Color(0xFF202124),
scaffoldBackgroundColor: new Color(0xFF202124),
backgroundColor: new Color(0xFF202124),
errorColor: new Color(0xFFB00020),
buttonTheme: new ButtonThemeData(
colorScheme: colorScheme,
textTheme: ButtonTextTheme.primary
)
);
return baseTheme.copyWith(
textTheme: _buildTextTheme(baseTheme.textTheme),
primaryTextTheme: _buildTextTheme(baseTheme.primaryTextTheme),
accentTextTheme: _buildTextTheme(baseTheme.accentTextTheme)
);
}
private static ThemeData _buildLightTheme()
{
Color primaryColor = new Color(0xFF0175c2);
Color secondaryColor = new Color(0xFF13B9FD);
ColorScheme colorScheme = ColorScheme.light().copyWith(
primary: primaryColor,
secondary: secondaryColor
);
ThemeData baseTheme = new ThemeData(
brightness: Brightness.light,
accentColorBrightness: Brightness.dark,
colorScheme: colorScheme,
primaryColor: primaryColor,
buttonColor: primaryColor,
indicatorColor: Colors.white,
toggleableActiveColor: new Color(0xFF1E88E5),
splashColor: Colors.white24,
splashFactory: InkRipple.splashFactory,
accentColor: secondaryColor,
canvasColor: Colors.white,
scaffoldBackgroundColor: Colors.white,
backgroundColor: Colors.white,
errorColor: new Color(0xFFB00020),
buttonTheme: new ButtonThemeData(
colorScheme: colorScheme,
textTheme: ButtonTextTheme.primary
)
);
return baseTheme.copyWith(
textTheme: _buildTextTheme(baseTheme.textTheme),
primaryTextTheme: _buildTextTheme(baseTheme.primaryTextTheme),
accentTextTheme: _buildTextTheme(baseTheme.accentTextTheme)
);
}
}
}

3
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/themes.cs.meta


fileFormatVersion: 2
guid: 3941efd4d8554df2a6f53ad10cc6ca56
timeCreated: 1612324365

96
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/updater.cs


using System;
using System.Collections.Generic;
using System.Diagnostics;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery.gallery
{
public delegate Future<string> UpdateUrlFetcher();
internal class Updater : StatefulWidget
{
public Updater(UpdateUrlFetcher updateUrlFetcher, Widget child = null, Key key = null)
:
base(key: key)
{
D.assert(updateUrlFetcher != null);
this.child = child;
this.updateUrlFetcher = updateUrlFetcher;
}
public readonly UpdateUrlFetcher updateUrlFetcher;
public readonly Widget child;
public override State createState()
{
return new UpdaterState();
}
}
internal class UpdaterState : State<Updater>
{
private static void launch(string url)
{
Process.Start(url);
}
public override void initState()
{
base.initState();
this._checkForUpdates();
}
private static DateTime _lastUpdateCheck;
private void _checkForUpdates()
{
// Only prompt once a day
if (_lastUpdateCheck != null &&
DateTime.Now - _lastUpdateCheck < new TimeSpan(1, 0, 0, 0))
return; // We already checked for updates recently
_lastUpdateCheck = DateTime.Now;
this.widget.updateUrlFetcher.Invoke().then(updateUrl =>
{
if (updateUrl != null)
material_.showDialog<bool>(context: this.context, builder: this._buildDialog).then(wantsUpdate =>
{
if (wantsUpdate != null && (bool) wantsUpdate)
launch((string) updateUrl);
});
});
}
private Widget _buildDialog(BuildContext context)
{
ThemeData theme = Theme.of(context);
TextStyle dialogTextStyle =
theme.textTheme.subtitle1.copyWith(color: theme.textTheme.caption.color);
return new AlertDialog(
title: new Text("Update UIWidgets Gallery?"),
content: new Text("A newer version is available.", style: dialogTextStyle),
actions: new List<Widget>
{
new FlatButton(
child: new Text("NO THANKS"),
onPressed: () => { Navigator.pop(context, false); }
),
new FlatButton(
child: new Text("UPDATE"),
onPressed: () => { Navigator.pop(context, true); }
)
}
);
}
public override Widget build(BuildContext context)
{
return this.widget.child;
}
}
}

3
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/updater.cs.meta


fileFormatVersion: 2
guid: 16139f3d73b447de87560f29d24aff3e
timeCreated: 1612323458
正在加载...
取消
保存