浏览代码

fix errors in shrine demos

/zgh-devtools
guanghuispark 4 年前
当前提交
d7906504
共有 12 个文件被更改,包括 263 次插入217 次删除
  1. 171
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/app.cs
  2. 52
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/backdrop.cs
  3. 58
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/category_menu_page.cs
  4. 97
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/expanding_bottom_sheet.cs
  5. 5
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/home.cs
  6. 4
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/login.cs
  7. 54
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/shopping_cart.cs
  8. 12
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/supplemental/asymmetric_view.cs
  9. 8
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/supplemental/product_card.cs
  10. 8
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/supplemental/product_columns.cs
  11. 6
      com.unity.uiwidgets/Runtime/widgets/basic.cs
  12. 5
      com.unity.uiwidgets/Runtime/widgets/navigator.cs

171
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/app.cs


using System;
using UIWidgetsGallery.demo.shrine.supplemental;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.ui;

{
public class appUtils
{
public static Route _getRoute(RouteSettings settings) {
if (settings.name != "/login") {
return null;
}
return new MaterialPageRoute(
settings: settings,
builder: (BuildContext context) => new LoginPage(),
fullscreenDialog: true
);
}
public static readonly ThemeData _kShrineTheme = _buildShrineTheme();
static IconThemeData _customIconTheme(IconThemeData original) {
return original.copyWith(color: shrineColorsUtils.kShrineBrown900);
}
static ThemeData _buildShrineTheme() {
ThemeData _base = ThemeData.light();
return _base.copyWith(
colorScheme: kShrineColorScheme,
accentColor: shrineColorsUtils.kShrineBrown900,
primaryColor: shrineColorsUtils.kShrinePink100,
buttonColor: shrineColorsUtils.kShrinePink100,
scaffoldBackgroundColor: shrineColorsUtils.kShrineBackgroundWhite,
cardColor: shrineColorsUtils.kShrineBackgroundWhite,
textSelectionColor: shrineColorsUtils.kShrinePink100,
errorColor: shrineColorsUtils.kShrineErrorRed,
buttonTheme: new ButtonThemeData(
colorScheme: kShrineColorScheme,
textTheme: ButtonTextTheme.normal
),
primaryIconTheme: _customIconTheme(_base.iconTheme),
inputDecorationTheme: new InputDecorationTheme(border: new CutCornersBorder()),
textTheme: _buildShrineTextTheme(_base.textTheme),
primaryTextTheme: _buildShrineTextTheme(_base.primaryTextTheme),
accentTextTheme: _buildShrineTextTheme(_base.accentTextTheme),
iconTheme: _customIconTheme(_base.iconTheme)
);
}
static TextTheme _buildShrineTextTheme(TextTheme _base) {
return _base.copyWith(
headline5: _base.headline5.copyWith(fontWeight: FontWeight.w500),
headline6: _base.headline6.copyWith(fontSize: 18.0f),
caption: _base.caption.copyWith(fontWeight: FontWeight.w400, fontSize: 14.0f),
bodyText1: _base.bodyText1.copyWith(fontWeight: FontWeight.w500, fontSize: 16.0f),
button: _base.button.copyWith(fontWeight: FontWeight.w500, fontSize: 14.0f)
).apply(
fontFamily: "Raleway",
displayColor: shrineColorsUtils.kShrineBrown900,
bodyColor: shrineColorsUtils.kShrineBrown900
);
}
static ColorScheme kShrineColorScheme = new ColorScheme(
primary: shrineColorsUtils.kShrinePink100,
primaryVariant: shrineColorsUtils.kShrineBrown900,
secondary: shrineColorsUtils.kShrinePink50,
secondaryVariant: shrineColorsUtils.kShrineBrown900,
surface: shrineColorsUtils.kShrineSurfaceWhite,
background: shrineColorsUtils.kShrineBackgroundWhite,
error: shrineColorsUtils.kShrineErrorRed,
onPrimary: shrineColorsUtils.kShrineBrown900,
onSecondary: shrineColorsUtils.kShrineBrown900,
onSurface: shrineColorsUtils.kShrineBrown900,
onBackground: shrineColorsUtils.kShrineBrown900,
onError: shrineColorsUtils.kShrineSurfaceWhite,
brightness: Brightness.light
);
}
public class _ShrineAppState : State<ShrineApp> {//with SingleTickerProviderStateMixin {
public class _ShrineAppState : SingleTickerProviderStateMixin<ShrineApp> {//with SingleTickerProviderStateMixin {
AnimationController _controller;

vsync: this,
duration: Durantion(milliseconds: 450),
value: 1.0
duration: TimeSpan.FromMilliseconds(450),
value: 1.0f
);
}

title: "Shrine",
home: HomePage(
backdrop: Backdrop(
frontLayer: ProductPage(),
backLayer: CategoryMenuPage(onCategoryTap: () => _controller.forward()),
home: new HomePage(
backdrop: new Backdrop(
frontLayer: new ProductPage(),
backLayer: new CategoryMenuPage(onCategoryTap: () => _controller.forward()),
expandingBottomSheet: ExpandingBottomSheet(hideController: _controller),
expandingBottomSheet: new ExpandingBottomSheet(hideController: _controller)
onGenerateRoute: _getRoute,
theme: _kShrineTheme.copyWith(platform: Theme.of(context).platform),
onGenerateRoute: appUtils._getRoute,
theme: appUtils._kShrineTheme.copyWith(platform: Theme.of(context).platform)
Route<object> _getRoute(RouteSettings settings) {
if (settings.name != '/login') {
return null;
}
return new MaterialPageRoute(
settings: settings,
builder: (BuildContext context) => LoginPage(),
fullscreenDialog: true
);
}
public readonly ThemeData _kShrineTheme = _buildShrineTheme();
IconThemeData _customIconTheme(IconThemeData original) {
return original.copyWith(color: shrineColorsUtils.kShrineBrown900);
}
ThemeData _buildShrineTheme() {
ThemeData _base = ThemeData.light();
return _base.copyWith(
colorScheme: kShrineColorScheme,
accentColor: shrineColorsUtils.kShrineBrown900,
primaryColor: shrineColorsUtils.kShrinePink100,
buttonColor: shrineColorsUtils.kShrinePink100,
scaffoldBackgroundColor: shrineColorsUtils.kShrineBackgroundWhite,
cardColor: shrineColorsUtils.kShrineBackgroundWhite,
textSelectionColor: shrineColorsUtils.kShrinePink100,
errorColor: shrineColorsUtils.kShrineErrorRed,
buttonTheme: new ButtonThemeData(
colorScheme: kShrineColorScheme,
textTheme: ButtonTextTheme.normal
),
primaryIconTheme: _customIconTheme(_base.iconTheme),
inputDecorationTheme: new InputDecorationTheme(border: CutCornersBorder()),
textTheme: _buildShrineTextTheme(_base.textTheme),
primaryTextTheme: _buildShrineTextTheme(_base.primaryTextTheme),
accentTextTheme: _buildShrineTextTheme(_base.accentTextTheme),
iconTheme: _customIconTheme(_base.iconTheme)
);
}
TextTheme _buildShrineTextTheme(TextTheme _base) {
return _base.copyWith(
headline5: _base.headline5.copyWith(fontWeight: FontWeight.w500),
headline6: _base.headline6.copyWith(fontSize: 18.0f),
caption: _base.caption.copyWith(fontWeight: FontWeight.w400, fontSize: 14.0f),
bodyText1: _base.bodyText1.copyWith(fontWeight: FontWeight.w500, fontSize: 16.0f),
button: _base.button.copyWith(fontWeight: FontWeight.w500, fontSize: 14.0f)
).apply(
fontFamily: "Raleway",
displayColor: shrineColorsUtils.kShrineBrown900,
bodyColor: shrineColorsUtils.kShrineBrown900
);
}
ColorScheme kShrineColorScheme = new ColorScheme(
primary: shrineColorsUtils.kShrinePink100,
primaryVariant: shrineColorsUtils.kShrineBrown900,
secondary: shrineColorsUtils.kShrinePink50,
secondaryVariant: shrineColorsUtils.kShrineBrown900,
surface: shrineColorsUtils.kShrineSurfaceWhite,
background: shrineColorsUtils.kShrineBackgroundWhite,
error: shrineColorsUtils.kShrineErrorRed,
onPrimary: shrineColorsUtils.kShrineBrown900,
onSecondary: shrineColorsUtils.kShrineBrown900,
onSurface: shrineColorsUtils.kShrineBrown900,
onBackground: shrineColorsUtils.kShrineBrown900,
onError: shrineColorsUtils.kShrineSurfaceWhite,
brightness: Brightness.light
);
}

52
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/backdrop.cs


children: new List<Widget>{
new GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: onTap,
onTap: () => { onTap?.Invoke();},
child: new Container(
height: 40.0f,
alignment: AlignmentDirectional.centerStart

);
}
}
public delegate void OnPress();
Key key,
Animation<float> listenable,
Delegate onPress,
Widget frontTitle,
Widget backTitle
Key key = null,
Animation<float> listenable = null,
OnPress onPress = null,
Widget frontTitle = null,
Widget backTitle = null
) : base(key: key, listenable: listenable)
{
D.assert(frontTitle != null);

this.onPress = onPress;
}
public readonly Delegate onPress;
//public delegate void onPress(); [!!!]
public readonly OnPress onPress;
public readonly Widget frontTitle;
public readonly Widget backTitle;

width: 72.0f,
child: new IconButton(
padding: EdgeInsets.only(right: 8.0f),
onPressed: onPress,
onPressed: ()=> { onPress?.Invoke();},
child: new ImageIcon(new FileImage("packages/shrine_images/slanted_menu.png"))
child: new Container(
width: 44.0f,
height: 44.0f,
decoration: new BoxDecoration(
image: new DecorationImage(
image: new FileImage(
file: "logo.png"
)
),
shape: BoxShape.circle
)
)
child: new ImageIcon(new FileImage("packages/shrine_images/diamond.png"))
child: new Container(
width: 44.0f,
height: 44.0f,
decoration: new BoxDecoration(
image: new DecorationImage(
image: new FileImage(
file: "logo.png"
)
),
shape: BoxShape.circle
)
)
)
})
)

new IconButton(
icon: new Icon(Icons.search),
onPressed: () => {
Navigator.push<Void>(
Navigator.push<object>(
new MaterialPageRoute<Void>(builder: (BuildContext context) => new LoginPage())
new MaterialPageRoute(builder: (BuildContext context2) => new LoginPage())
);
}
),

Navigator.push<void>(
Navigator.push<object>(
new MaterialPageRoute<void>(builder: (BuildContext context) => new LoginPage()),
new MaterialPageRoute(builder: (BuildContext context2) => new LoginPage())
);
}
),

58
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/category_menu_page.cs


}
},
child: model.selectedCategory == category
? new Column(
children: new List<Widget>
{
new SizedBox(height: 16.0f),
new Text(
? new Container(
child:new Column(
children: new List<Widget>
{
new SizedBox(height: 16.0f),
new Text(
categoryString,
style: theme.textTheme.bodyText1,
textAlign: TextAlign.center
),
new SizedBox(height: 14.0f),
new Container(
width: 70.0f,
height: 2.0f,
color: shrineColorsUtils.kShrinePink400
),
}
)
)
: new Container(
child: new Padding(
padding: EdgeInsets.symmetric(vertical: 16.0f),
child: new Text(
style: theme.textTheme.bodyText1,
style: theme.textTheme.bodyText1.copyWith(
color: shrineColorsUtils.kShrineBrown900.withAlpha(153)
),
),
new SizedBox(height: 14.0f),
new Container(
width: 70.0f,
height: 2.0f,
color: shrineColorsUtils.kShrinePink400
),
}
)
: new Padding(
padding: EdgeInsets.symmetric(vertical: 16.0f),
child: new Text(
categoryString,
style: theme.textTheme.bodyText1.copyWith(
color: shrineColorsUtils.kShrineBrown900.withAlpha(153)
),
textAlign: TextAlign.center
)
)
)
)

public override Widget build(BuildContext context) {
var count = Enum.GetNames(typeof(Category)).Length;
List<Widget> widgets = new List<Widget>();
for (int i = 0;i<count;i++)
{
widgets.Add( _buildCategory((Category)i, context));
}
children: Category.values.map((Category c) => _buildCategory(c, context)).toList(),
children: widgets
)
)
);

97
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/expanding_bottom_sheet.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;
using UIWidgetsGallery.demo.shrine.model;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.async2;

public static readonly float _kCornerRadius = 24.0f;
public static readonly float _kWidthForCartIcon = 64.0f;
Animation<T> _getEmphasizedEasingAnimation<T>(
public static Animation<T> _getEmphasizedEasingAnimation<T>(
T begin,
T peak,
T end,

public override State createState() => new _ExpandingBottomSheetState();
static _ExpandingBottomSheetState of(BuildContext context, bool isNullOk = false) {
public static _ExpandingBottomSheetState of(BuildContext context, bool isNullOk = false) {
D.assert(context != null);
_ExpandingBottomSheetState result = context.findAncestorStateOfType<_ExpandingBottomSheetState>();
if (isNullOk || result != null) {

class _ExpandingBottomSheetState : State<ExpandingBottomSheet> { //with TickerProviderStateMixin {
public class _ExpandingBottomSheetState : TickerProviderStateMixin<ExpandingBottomSheet> { //with TickerProviderStateMixin {
public readonly GlobalKey _expandingBottomSheetKey = GlobalKey.key(debugLabel: "Expanding bottom sheet");
float _width = expanding_buttom_sheetUtils._kWidthForCartIcon;

public override void initState() {
base.initState();
_controller = new AnimationController(
duration: Duration(milliseconds: 500),
duration: TimeSpan.FromMilliseconds(500),
vsync: this
);
}

)
);
} else {
return _getEmphasizedEasingAnimation(
return expanding_buttom_sheetUtils._getEmphasizedEasingAnimation(
peak: _getPeakPoint(begin: _width, end: screenWidth),
peak: expanding_buttom_sheetUtils._getPeakPoint(begin: _width, end: screenWidth),
parent: new CurvedAnimation(parent: _controller.view, curve: new Interval(0.0f, 0.87f)),
parent: new CurvedAnimation(parent: _controller.view, curve: new Interval(0.0f, 0.87f))
);
}
}

return _getEmphasizedEasingAnimation(
return expanding_buttom_sheetUtils._getEmphasizedEasingAnimation(
begin: expanding_buttom_sheetUtils._kCartHeight,
peak: expanding_buttom_sheetUtils._kCartHeight + (screenHeight - expanding_buttom_sheetUtils._kCartHeight) * expanding_buttom_sheetUtils._kPeakVelocityProgress,
end: screenHeight,

)
);
} else {
return _getEmphasizedEasingAnimation(
return expanding_buttom_sheetUtils._getEmphasizedEasingAnimation(
begin: expanding_buttom_sheetUtils._kCornerRadius,
peak: expanding_buttom_sheetUtils._getPeakPoint(begin: expanding_buttom_sheetUtils._kCornerRadius, end: 0.0f),
end: 0.0f,

}
// Closes the ExpandingBottomSheet if it's open or opening, otherwise does nothing.
void close() {
public void close() {
if (_isOpen) {
_controller.reverse();
}

}
Widget _buildThumbnails(int numProducts) {
return new ExcludeSemantics(
return new Container(
child: new Opacity(
opacity: _thumbnailOpacityAnimation.value,
child: new Column(

new AnimatedPadding(
padding: _cartPaddingFor(numProducts),
child: new Icon(Icons.shopping_cart),
duration: new Duration(milliseconds: 225)
duration: TimeSpan.FromMilliseconds(225)
),
new Container(
// Accounts for the overflow number

Widget _buildCart(BuildContext context, Widget child) {
AppStateModel model = ScopedModel.of<AppStateModel>(context);
AppStateModel model = ScopedModel<AppStateModel>.of(context);
int numProducts = model.productsInCart.Keys.Count;
int totalCartQuantity = model.totalCartQuantity;
Size screenSize = MediaQuery.of(context).size;

_thumbnailOpacityAnimation = _getThumbnailOpacityAnimation();
_cartOpacityAnimation = _getCartOpacityAnimation();
return Semantics(
button: true,
value: $"Shopping cart, {totalCartQuantity} items",
child: new Container(
return new Container(
animationDuration: Duration(milliseconds: 0),
animationDuration: TimeSpan.FromMilliseconds(0),
shape: new BeveledRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(_shapeAnimation.value)

? _buildShoppingCartPage()
: _buildThumbnails(numProducts)
)
)
_slideAnimation = _getEmphasizedEasingAnimation(
_slideAnimation = expanding_buttom_sheetUtils._getEmphasizedEasingAnimation(
begin: new Offset(1.0f, 0.0f),
peak: new Offset(expanding_buttom_sheetUtils._kPeakVelocityProgress, 0.0f),
end: new Offset(0.0f, 0.0f),

// Closes the cart if the cart is open, otherwise exits the app (this should
// only be relevant for Android).
Future<bool> _onWillPop() async {
if (!_isOpen) {
await SystemNavigator.pop();
return true;
Future<bool> _onWillPop() {
if (!_isOpen) {
//SystemNavigator.pop();
return Future.value(true).to<bool>();
return true;
return Future.value(true).to<bool>();
}

duration: Duration(milliseconds: 225),
duration: TimeSpan.FromMilliseconds(225),
curve: Curves.easeInOut,
vsync: this,
alignment: FractionalOffset.topLeft,

}
public class _ProductThumbnailRowState : State<ProductThumbnailRow> {
public readonly GlobalKey<AnimatedListState> _listKey = new GlobalKey<AnimatedListState>();
public readonly GlobalKey<AnimatedListState> _listKey = GlobalKey<AnimatedListState>.key();
_ListModel _list;
List<int> _internalList;

base.initState();
_list = new _ListModel(
listKey: _listKey,
initialItems: ScopedModel.of<AppStateModel>(context).productsInCart.keys.toList(),
initialItems: ScopedModel<AppStateModel>.of(context).productsInCart.Keys.ToList(),
);
);
AppStateModel model = ScopedModel.of<AppStateModel>(context);
AppStateModel model = ScopedModel<AppStateModel>.of(context);
Product product = model.getProductById(productId);
D.assert(product != null);
return product;

parent: animation
);
return new ProductThumbnail(thumbnailSize, opacity, _productWithId(_list[index]));
return new ProductThumbnail(thumbnailSize, opacity, _productWithId(_list.ElementAt(index)));
// If the lists are the same length, assume nothing has changed.
// If the internalList is shorter than the ListModel, an item has been removed.
// If the internalList is longer, then an item has been added.
// Update _internalList based on the model
_internalList = ScopedModel.of<AppStateModel>(context).productsInCart.keys.toList();
_internalList = ScopedModel<AppStateModel>.of(context).productsInCart.Keys.ToList();
HashSet<int> internalSet = new HashSet<int>(_internalList);
HashSet<int> listSet = new HashSet<int>(_list.list);

while (_internalList.Count != _list.length) {
int index = 0;
// Check bounds and that the list elements are the same
while (_internalList.isNotEmpty &&
while (_internalList.isNotEmpty() &&
_internalList[index] == _list[index]) {
_internalList[index] == _list.ElementAt(index)) {
index++;
}
}

public override Widget build(BuildContext context) {
return new ScopedModelDescendant<AppStateModel>(
builder: (BuildContext builder, Widget child, AppStateModel model) => _buildOverflow(model, context),
builder: (BuildContext builder, Widget child, AppStateModel model) => _buildOverflow(model, context)
);
}
}

height: 40.0f,
decoration: new BoxDecoration(
image: new DecorationImage(
image: new ExactAssetImage(
product.assetName,
package: product.assetPackage
image: new FileImage(
product.assetName
),
fit: BoxFit.cover
),

);
}
}
public delegate Widget RemovedItemBuilder(int item, BuildContext context, Animation<float> animation) ;
Delegate removedItemBuilder,
IEnumerable<int> initialItems
RemovedItemBuilder removedItemBuilder,
IEnumerable<int> initialItems = null
this.listKey = listKey;
this.removedItemBuilder = removedItemBuilder;
public delegate Widget removedItemBuilder(int item, BuildContext context, Animation<float> animation);
public RemovedItemBuilder removedItemBuilder;
public readonly List<int> _items;
AnimatedListState _animatedList

public void _insert(int index, int item) {
_items.Insert(index, item);
_animatedList.insertItem(index, duration: Duration(milliseconds: 225));
_animatedList.insertItem(index, duration: TimeSpan.FromMilliseconds(225));
}
public void remove(int product) {

}
}
public void _removeAt(int index) {
public void _removeAt(int index)
{
int removedItem = _items.ElementAt(index);
_items.RemoveAt(index);
_animatedList.removeItem(index, (BuildContext context, Animation<float> animation) =>{
return removedItemBuilder(removedItem, context, animation);

}
}
int operator [](int index) => _items[index];
public int ElementAt(int index) => _items[index];
int indexOf(int item) => _items.IndexOf(item);

5
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/home.cs


using System.Collections.Generic;
using UIWidgetsGallery.demo.shrine.model;
using UIWidgetsGallery.demo.shrine.supplemental;
using UIWidgetsGallery.gallery;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;

public override Widget build(BuildContext context) {
return new ScopedModelDescendant<AppStateModel>(
builder: (BuildContext context, Widget child, AppStateModel model) => {
return AsymmetricView(products: model.getProducts());
builder: (BuildContext context1, Widget child, AppStateModel model) => {
return new AsymmetricView(products: model.getProducts());
});
}
}

4
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/login.cs


icon: new BackButtonIcon(),
tooltip: MaterialLocalizations.of(context).backButtonTooltip,
onPressed: () => {
Navigator.of(context, rootNavigator: true).pop();
Navigator.of(context, rootNavigator: true).pop<object>();
}
)
),

borderRadius: BorderRadius.all(Radius.circular(7.0f))
),
onPressed: () => {
Navigator.of(context, rootNavigator: true).pop();
Navigator.of(context, rootNavigator: true).pop<object>();
}
),
new RaisedButton(

54
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/shopping_cart.cs


using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;

using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace UIWidgetsGallery.demo.shrine
{

}
class ShoppingCartPage : StatefulWidget {
public class ShoppingCartPage : StatefulWidget {
List<Widget> _createShoppingCartRows(AppStateModel model) {
return model.productsInCart.Keys
.map((int id) => new ShoppingCartRow(
product: model.getProductById(id),
quantity: model.productsInCart[id],
onPressed: () =>{
model.removeItemFromCart(id);
}
)
)
.toList();
List<Widget> _createShoppingCartRows(AppStateModel model)
{
List<Widget> widgets = null;
for (int id = 0; id < model.productsInCart.Count; id++)
{
widgets.Add(new ShoppingCartRow(
product: model.getProductById(id),
quantity: model.productsInCart[id],
onPressed: ()=> {
model.removeItemFromCart(id);
}
));
}
return widgets;
}
public override Widget build(BuildContext context) {

public override Widget build(BuildContext context) {
TextStyle smallAmountStyle = Theme.of(context).textTheme.bodyText2.copyWith(color: shrineColorsUtils.kShrineBrown600);
TextStyle largeAmountStyle = Theme.of(context).textTheme.headline4;
NumberFormat formatter = NumberFormat.simpleCurrency(
decimalDigits: 2,
locale: Localizations.localeOf(context).ToString()
);
return new Row(
children: new List<Widget>

child: new Text("TOTAL")
),
new Text(
formatter.format(model.totalCost),
$"${model.totalCost:F}",
style: largeAmountStyle
)
}

child: new Text("Subtotal:")
),
new Text(
formatter.format(model.subtotalCost),
$" $ {model.subtotalCost:F}",
style: smallAmountStyle
)
}

child: new Text("Shipping:")
),
new Text(
formatter.format(model.shippingCost),
$" $ {model.shippingCost:F}",
style: smallAmountStyle
)
}

child: new Text("Tax:")
),
new Text(
formatter.format(model.tax),
$"${model.tax:F}",
style: smallAmountStyle
)
}

public override Widget build(BuildContext context) {
NumberFormat formatter = NumberFormat.simpleCurrency(
decimalDigits: 0,
locale: Localizations.localeOf(context).ToString()
);
key: ValueKey<int>(product.id),
key: new ValueKey<int>(product.id),
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget>{
new SizedBox(

new Row(
children: new List<Widget>{
new Expanded(
child: new Text($"Quantity: {quantity}"),
child: new Text($"Quantity: {quantity}")
new Text($"x {formatter.format(product.price)}")
new Text($"x $ {product.price : D} ")
}
),
new Text(

12
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/supplemental/asymmetric_view.cs


public readonly List<Product> products;
List<Container> _buildColumns(BuildContext context) {
List<Widget> _buildColumns(BuildContext context) {
return new List<Container>();
return new List<Widget>();
List<Container> list = new List<Container>();
List<Widget> list = new List<Widget>();
var len = _listItemCount(products.Count());
for (int index = 0; index < len; index++)
{

}
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
List<Widget> widgets = _buildColumns(context);
children: _buildColumns(context),
children: widgets,
physics: new AlwaysScrollableScrollPhysics()
);
}

8
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/supplemental/product_card.cs


public override Widget build(BuildContext context) {
NumberFormat formatter = NumberFormat.simpleCurrency(
decimalDigits: 0,
locale: Localizations.localeOf(context).ToString()
);
ThemeData theme = Theme.of(context);
Image imageWidget = Image.asset(

),
new SizedBox(height: 4.0f),
new Text(
product == null ? "" : formatter.format(product.price),
$" $ { product.price:D}",
style: theme.textTheme.caption
),
}

8
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine/supplemental/product_columns.cs


new Padding(
padding: EdgeInsets.only(left: 28.0f),
child: top != null
? new ProductCard(
imageAspectRatio: imageAspectRatio,
product: top
?new SizedBox(
child: new ProductCard(
imageAspectRatio: imageAspectRatio,
product: top
)
)
: new SizedBox(
height: heightOfCards > 0 ? heightOfCards : spacerHeight

6
com.unity.uiwidgets/Runtime/widgets/basic.cs


public class Padding : SingleChildRenderObjectWidget {
public Padding(
Key key = null,
EdgeInsets padding = null,
EdgeInsetsGeometry padding = null,
Widget child = null
) : base(key, child) {
D.assert(padding != null);

public readonly EdgeInsets padding;
public readonly EdgeInsetsGeometry padding;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderPadding(

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<EdgeInsets>("padding", padding));
properties.add(new DiagnosticsProperty<EdgeInsetsGeometry>("padding", padding));
}
}

5
com.unity.uiwidgets/Runtime/widgets/navigator.cs


public static void pop<T>(BuildContext context, T result = default(T) ) {
of(context).pop<T>(result);
}
public static void pop(BuildContext context, object result = null ) {
of(context).pop(result);
}
public static void popUntil(BuildContext context, RoutePredicate predicate) {
of(context).popUntil(predicate);

正在加载...
取消
保存