Yuncong Zhang
6 年前
当前提交
dc7e8b0b
共有 10 个文件被更改,包括 2633 次插入 和 15 次删除
-
164Runtime/rendering/proxy_box.cs
-
36Runtime/widgets/basic.cs
-
32Samples/UIWidgetsGallery/gallery/demo.cs
-
18Samples/UIWidgetsGallery/gallery/demos.cs
-
217Samples/UIWidgetsGallery/demo/material/cards_demo.cs
-
3Samples/UIWidgetsGallery/demo/material/cards_demo.cs.meta
-
1001Tests/Resources/india_chettinad_silk_maker.png
-
88Tests/Resources/india_chettinad_silk_maker.png.meta
-
1001Tests/Resources/india_thanjavur_market.png
-
88Tests/Resources/india_thanjavur_market.png.meta
|
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
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 Image = Unity.UIWidgets.widgets.Image; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace UIWidgetsGallery.gallery { |
|||
class CardsDemoConstants { |
|||
public static readonly List<TravelDestination> destinations = new List<TravelDestination> { |
|||
new TravelDestination( |
|||
assetName: "india_thanjavur_market", |
|||
title: "Top 10 Cities to Visit in Tamil Nadu", |
|||
description: new List<string> { |
|||
"Number 10", |
|||
"Thanjavur", |
|||
"Thanjavur, Tamil Nadu" |
|||
} |
|||
), |
|||
new TravelDestination( |
|||
assetName: "india_chettinad_silk_maker", |
|||
title: "Artisans of Southern India", |
|||
description: new List<string> { |
|||
"Silk Spinners", |
|||
"Chettinad", |
|||
"Sivaganga, Tamil Nadu" |
|||
} |
|||
) |
|||
}; |
|||
} |
|||
|
|||
public class TravelDestination { |
|||
public TravelDestination( |
|||
string assetName = null, |
|||
string title = null, |
|||
List<string> description = null |
|||
) { |
|||
this.assetName = assetName; |
|||
this.title = title; |
|||
this.description = description; |
|||
} |
|||
|
|||
public readonly string assetName; |
|||
public readonly string title; |
|||
public readonly List<string> description; |
|||
|
|||
public bool isValid { |
|||
get { return this.assetName != null && this.title != null && this.description?.Count == 3; } |
|||
} |
|||
} |
|||
|
|||
|
|||
public class TravelDestinationItem : StatelessWidget { |
|||
public TravelDestinationItem(Key key = null, TravelDestination destination = null, ShapeBorder shape = null) |
|||
: base(key: key) { |
|||
D.assert(destination != null && destination.isValid); |
|||
this.destination = destination; |
|||
this.shape = shape; |
|||
} |
|||
|
|||
public const float height = 366.0f; |
|||
public readonly TravelDestination destination; |
|||
public readonly ShapeBorder shape; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
ThemeData theme = Theme.of(context); |
|||
TextStyle titleStyle = theme.textTheme.headline.copyWith(color: Colors.white); |
|||
TextStyle descriptionStyle = theme.textTheme.subhead; |
|||
|
|||
return new SafeArea( |
|||
top: false, |
|||
bottom: false, |
|||
child: new Container( |
|||
padding: EdgeInsets.all(8.0f), |
|||
height: height, |
|||
child: new Card( |
|||
shape: this.shape, |
|||
child: new Column( |
|||
crossAxisAlignment: CrossAxisAlignment.start, |
|||
children: new List<Widget> { |
|||
new SizedBox( |
|||
height: 184.0f, |
|||
child: new Stack( |
|||
children: new List<Widget> { |
|||
Positioned.fill( |
|||
child: Image.asset(this.destination.assetName, |
|||
fit: BoxFit.cover |
|||
) |
|||
), |
|||
new Positioned( |
|||
bottom: 16.0f, |
|||
left: 16.0f, |
|||
right: 16.0f, |
|||
child: new FittedBox( |
|||
fit: BoxFit.scaleDown, |
|||
alignment: Alignment.centerLeft, |
|||
child: new Text(this.destination.title, |
|||
style: titleStyle |
|||
) |
|||
) |
|||
) |
|||
} |
|||
) |
|||
), |
|||
new Expanded( |
|||
child: new Padding( |
|||
padding: EdgeInsets.fromLTRB(16.0f, 16.0f, 16.0f, 0.0f), |
|||
child: new DefaultTextStyle( |
|||
softWrap: false, |
|||
overflow: TextOverflow.ellipsis, |
|||
style: descriptionStyle, |
|||
child: new Column( |
|||
crossAxisAlignment: CrossAxisAlignment.start, |
|||
children: new List<Widget> { |
|||
new Padding( |
|||
padding: EdgeInsets.only(bottom: 8.0f), |
|||
child: new Text(this.destination.description[0], |
|||
style: descriptionStyle.copyWith(color: Colors.black54) |
|||
) |
|||
), |
|||
new Text(this.destination.description[1]), |
|||
new Text(this.destination.description[2]) |
|||
} |
|||
) |
|||
) |
|||
) |
|||
), |
|||
ButtonTheme.bar( |
|||
child: new ButtonBar( |
|||
alignment: MainAxisAlignment.start, |
|||
children: new List<Widget> { |
|||
new FlatButton( |
|||
child: new Text("SHARE"), |
|||
textColor: Colors.amber.shade500, |
|||
onPressed: () => { |
|||
/* do nothing */ |
|||
} |
|||
), |
|||
new FlatButton( |
|||
child: new Text("EXPLORE"), |
|||
textColor: Colors.amber.shade500, |
|||
onPressed: () => { |
|||
/* do nothing */ |
|||
} |
|||
) |
|||
} |
|||
) |
|||
), |
|||
} |
|||
) |
|||
) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
|
|||
public class CardsDemo : StatefulWidget { |
|||
public const string routeName = "/material/cards"; |
|||
|
|||
public override State createState() { |
|||
return new _CardsDemoState(); |
|||
} |
|||
} |
|||
|
|||
class _CardsDemoState : State<CardsDemo> { |
|||
ShapeBorder _shape; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new Scaffold( |
|||
appBar: new AppBar( |
|||
title: new Text("Travel stream"), |
|||
actions: new List<Widget> { |
|||
new MaterialDemoDocumentationButton(CardsDemo.routeName), |
|||
new IconButton( |
|||
icon: new Icon( |
|||
Icons.sentiment_very_satisfied |
|||
), |
|||
onPressed: () => { |
|||
this.setState(() => { |
|||
this._shape = this._shape != null |
|||
? null |
|||
: new RoundedRectangleBorder( |
|||
borderRadius: BorderRadius.only( |
|||
topLeft: Radius.circular(16.0f), |
|||
topRight: Radius.circular(16.0f), |
|||
bottomLeft: Radius.circular(2.0f), |
|||
bottomRight: Radius.circular(2.0f) |
|||
) |
|||
); |
|||
}); |
|||
} |
|||
) |
|||
} |
|||
), |
|||
body: new ListView( |
|||
itemExtent: TravelDestinationItem.height, |
|||
padding: EdgeInsets.only(top: 8.0f, left: 8.0f, right: 8.0f), |
|||
children: CardsDemoConstants.destinations.Select<TravelDestination, Widget>( |
|||
(TravelDestination destination) => { |
|||
return new Container( |
|||
margin: EdgeInsets.only(bottom: 8.0f), |
|||
child: new TravelDestinationItem( |
|||
destination: destination, |
|||
shape: this._shape |
|||
) |
|||
); |
|||
}).ToList() |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f199ea32d87544c892f57b8af0fcbb03 |
|||
timeCreated: 1553136548 |
1001
Tests/Resources/india_chettinad_silk_maker.png
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 759295bbc368246a0877963ba053ed5d |
|||
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: |
1001
Tests/Resources/india_thanjavur_market.png
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 69711c649948f4cb1ad20b82f1926a29 |
|||
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: |
撰写
预览
正在加载...
取消
保存
Reference in new issue