浏览代码

Temp store.

/main
Yuncong Zhang 6 年前
当前提交
ecfc433b
共有 9 个文件被更改,包括 259 次插入150 次删除
  1. 4
      Samples/UIWidgetsGallery/demo/material/buttons_demo.cs
  2. 11
      Samples/UIWidgetsGallery/gallery/app.cs
  3. 12
      Samples/UIWidgetsGallery/gallery/backdrop.cs
  4. 262
      Samples/UIWidgetsGallery/gallery/home.cs
  5. 12
      Samples/UIWidgetsGallery/GalleryMain.cs
  6. 13
      Tests/Resources/unity.png
  7. 88
      Tests/Resources/unity.png.meta
  8. 7
      Samples/UIWidgetsGallery/main.cs
  9. 0
      /Samples/UIWidgetsGallery/GalleryMain.cs.meta

4
Samples/UIWidgetsGallery/demo/material/buttons_demo.cs


const String _outlineCode = "buttons_outline";
const String _dropdownText =
"A dropdown button displays a menu that\"s used to select a value from a " +
"A dropdown button displays a menu that's used to select a value from a " +
"small set of values. The button displays the current value and a down " +
"arrow.";

"IconButtons are appropriate for toggle buttons that allow a single choice " +
"to be selected or deselected, such as adding or removing an item\"s star.";
"to be selected or deselected, such as adding or removing an item's star.";
const String _iconCode = "buttons_icon";

11
Samples/UIWidgetsGallery/gallery/app.cs


VoidCallback onSendFeedback = null,
bool testMode = false
) : base(key: key) {
this.updateUrlFetcher = updateUrlFetcher;
this.enablePerformanceOverlay = enablePerformanceOverlay;
this.enableRasterCacheImagesCheckerboard = enableRasterCacheImagesCheckerboard;
this.enableOffscreenLayersCheckerboard = enableOffscreenLayersCheckerboard;
this.onSendFeedback = onSendFeedback;
this.testMode = testMode;
}
public readonly UpdateUrlFetcher updateUrlFetcher;

if (this._options.timeDilation != newOptions.timeDilation) {
this._timeDilationTimer?.cancel();
this._timeDilationTimer = null;
if (newOptions.timeDilation > 1.0) {
// We delay the time dilation change long enough that the user can see
// that UI has started reacting and then we slam on the brakes so that
// they see that the time is in fact now dilated.
if (newOptions.timeDilation > 1.0f) {
this._timeDilationTimer = Window.instance.run(new TimeSpan(0, 0, 0, 0, 150),
() => { SchedulerBinding.instance.timeDilation = newOptions.timeDilation; });
} else {

12
Samples/UIWidgetsGallery/gallery/backdrop.cs


public class Backdrop : StatefulWidget {
public Backdrop(
Widget frontAction,
Widget frontTitle,
Widget frontHeading,
Widget frontLayer,
Widget backTitle,
Widget backLayer
Widget frontAction = null,
Widget frontTitle = null,
Widget frontHeading = null,
Widget frontLayer = null,
Widget backTitle = null,
Widget backLayer = null
) {
this.frontAction = frontAction;
this.frontTitle = frontTitle;

262
Samples/UIWidgetsGallery/gallery/home.cs


decoration: new BoxDecoration(
image: new DecorationImage(
image: new AssetImage(
"logos/unity.png")
"unity.png")
)
)
)

public static bool showPreviewBanner = true;
public override State createState() {
// return new _GalleryHomeState();
return null;
return new _GalleryHomeState();
// class _GalleryHomeState : SingleTickerProviderStateMixin<GalleryHome> {
// static readonly GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>.key();
// AnimationController _controller;
// GalleryDemoCategory _category;
//
// static Widget _topHomeLayout(Widget currentChild, List<Widget> previousChildren) {
// List<Widget> children = previousChildren;
// if (currentChild != null) {
// children = children.ToList();
// children.Add(currentChild);
// }
//
// return new Stack(
// children: children,
// alignment: Alignment.topCenter
// );
// }
//
// public static AnimatedSwitcherLayoutBuilder _centerHomeLayout = AnimatedSwitcher.defaultLayoutBuilder;
//
// public override void initState() {
// base.initState();
// this._controller = new AnimationController(
// duration: new TimeSpan(0, 0, 0, 0, 600),
// debugLabel: "preview banner",
// vsync: this
// );
// this._controller.forward();
// }
//
// public override void dispose() {
// this._controller.dispose();
// base.dispose();
// }
//
// public override Widget build(BuildContext context) {
// ThemeData theme = Theme.of(context);
// bool isDark = theme.brightness == Brightness.dark;
// MediaQueryData media = MediaQuery.of(context);
// bool centerHome = media.orientation == Orientation.portrait && media.size.height < 800.0;
//
// Curve switchOutCurve = new Interval(0.4f, 1.0f, curve: Curves.fastOutSlowIn);
// Curve switchInCurve = new Interval(0.4f, 1.0f, curve: Curves.fastOutSlowIn);
//
// Widget home = new Scaffold(
// key: _scaffoldKey,
// backgroundColor: isDark ? HomeUtils._kUIWidgetsBlue : theme.primaryColor,
// body: new SafeArea(
// bottom: false,
// child: new WillPopScope(
// onWillPop: () => {
// // Pop the category page if Android back button is pressed.
// if (this._category != null) {
// this.setState(() => this._category = null);
// return Promise<bool>.Resolved(false);
// }
// return Promise<bool>.Resolved(true);
// },
// child: new Backdrop(
// backTitle: new Text("Options"),
// backLayer: this.widget.optionsPage,
// frontAction: new AnimatedSwitcher(
// duration: HomeUtils._kFrontLayerSwitchDuration,
// switchOutCurve: switchOutCurve,
// switchInCurve: switchInCurve,
// child: this._category == null
// ? (Widget) new _UIWidgetsLogo()
// : new IconButton(
// icon: new BackButtonIcon(),
// tooltip: "Back",
// onPressed: () => this.setState(() => this._category = null)
// )
// ),
// frontTitle: new AnimatedSwitcher(
// duration: HomeUtils._kFrontLayerSwitchDuration,
// child: this._category == null
// ? new Text("Flutter gallery")
// : new Text(this._category.name)
// ),
// frontHeading: this.widget.testMode ? null : new Container(height: 24.0f),
// frontLayer: new AnimatedSwitcher(
// duration: HomeUtils._kFrontLayerSwitchDuration,
// switchOutCurve: switchOutCurve,
// switchInCurve: switchInCurve,
// layoutBuilder: centerHome ? _centerHomeLayout : _topHomeLayout,
// child: this._category != null
// ? (Widget) new _DemosPage(this._category)
// : new _CategoriesPage(
// categories: DemoUtils.kAllGalleryDemoCategories,
// onCategoryTap: (GalleryDemoCategory category) => {
// this.setState(() => this._category = category);
// }
// )
// )
// )
// )
// )
// );
//
// D.assert(() => {
// GalleryHome.showPreviewBanner = false;
// return true;
// });
//
// if (GalleryHome.showPreviewBanner) {
// home = new Stack(
// fit: StackFit.expand,
// children: new List<Widget> {
// home,
// new FadeTransition(
// opacity: new CurvedAnimation(parent: this._controller, curve: Curves.easeInOut),
// child: new Banner(
// message: "PREVIEW",
// location: BannerLocation.topEnd
// )
// )
// }
// );
// }
// home = new AnnotatedRegion<SystemUiOverlayStyle>(
// child: home,
// value: SystemUiOverlayStyle.light
// );
//
// return home;
// }
// }
}
class _GalleryHomeState : SingleTickerProviderStateMixin<GalleryHome> {
static readonly GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>.key();
AnimationController _controller;
GalleryDemoCategory _category;
static Widget _topHomeLayout(Widget currentChild, List<Widget> previousChildren) {
List<Widget> children = previousChildren;
if (currentChild != null) {
children = children.ToList();
children.Add(currentChild);
}
return new Stack(
children: children,
alignment: Alignment.topCenter
);
}
public static AnimatedSwitcherLayoutBuilder _centerHomeLayout = AnimatedSwitcher.defaultLayoutBuilder;
public override void initState() {
base.initState();
this._controller = new AnimationController(
duration: new TimeSpan(0, 0, 0, 0, 600),
debugLabel: "preview banner",
vsync: this
);
this._controller.forward();
}
public override void dispose() {
this._controller.dispose();
base.dispose();
}
public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
bool isDark = theme.brightness == Brightness.dark;
MediaQueryData media = MediaQuery.of(context);
bool centerHome = media.orientation == Orientation.portrait && media.size.height < 800.0;
Curve switchOutCurve = new Interval(0.4f, 1.0f, curve: Curves.fastOutSlowIn);
Curve switchInCurve = new Interval(0.4f, 1.0f, curve: Curves.fastOutSlowIn);
Widget home = new Scaffold(
key: _scaffoldKey,
backgroundColor: isDark ? HomeUtils._kUIWidgetsBlue : theme.primaryColor,
body: new SafeArea(
bottom: false,
child: new WillPopScope(
onWillPop: () => {
if (this._category != null) {
this.setState(() => this._category = null);
return Promise<bool>.Resolved(false);
}
return Promise<bool>.Resolved(true);
},
child: new Backdrop(
backTitle: new Text("Options"),
backLayer: this.widget.optionsPage,
frontAction: new AnimatedSwitcher(
duration: HomeUtils._kFrontLayerSwitchDuration,
switchOutCurve: switchOutCurve,
switchInCurve: switchInCurve,
child: this._category == null
? (Widget) new _UIWidgetsLogo()
: new IconButton(
icon: new BackButtonIcon(),
tooltip: "Back",
onPressed: () => this.setState(() => this._category = null)
)
),
frontTitle: new AnimatedSwitcher(
duration: HomeUtils._kFrontLayerSwitchDuration,
child: this._category == null
? new Text("Flutter gallery")
: new Text(this._category.name)
),
frontHeading: this.widget.testMode ? null : new Container(height: 24.0f),
frontLayer: new AnimatedSwitcher(
duration: HomeUtils._kFrontLayerSwitchDuration,
switchOutCurve: switchOutCurve,
switchInCurve: switchInCurve,
layoutBuilder: centerHome ? _centerHomeLayout : _topHomeLayout,
child: this._category != null
? (Widget) new _DemosPage(this._category)
: new _CategoriesPage(
categories: DemoUtils.kAllGalleryDemoCategories,
onCategoryTap: (GalleryDemoCategory category) => {
this.setState(() => this._category = category);
}
)
)
)
)
)
);
D.assert(() => {
GalleryHome.showPreviewBanner = false;
return true;
});
if (GalleryHome.showPreviewBanner) {
home = new Stack(
fit: StackFit.expand,
children: new List<Widget> {
home,
new FadeTransition(
opacity: new CurvedAnimation(parent: this._controller, curve: Curves.easeInOut),
child: new Banner(
message: "PREVIEW",
location: BannerLocation.topEnd
)
)
}
);
}
home = new AnnotatedRegion<SystemUiOverlayStyle>(
child: home,
value: SystemUiOverlayStyle.light
);
return home;
}
}
}

12
Samples/UIWidgetsGallery/GalleryMain.cs


using UIWidgetsGallery.gallery;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.material;
using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery {
public class GalleryMain : UIWidgetsPanel {
protected override Widget createWidget() {
return new GalleryApp();
}
}
}

13
Tests/Resources/unity.png

之前 之后
宽度: 224  |  高度: 224  |  大小: 3.3 KiB

88
Tests/Resources/unity.png.meta


fileFormatVersion: 2
guid: e0f035e3c6f0247b9ba5aab8669a7f0a
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

7
Samples/UIWidgetsGallery/main.cs


using Unity.UIWidgets.engine;
namespace UIWidgetsGallery {
public class GalleryMain : UIWidgetsPanel {
}
}

/Samples/UIWidgetsGallery/main.cs.meta → /Samples/UIWidgetsGallery/GalleryMain.cs.meta

正在加载...
取消
保存