public ActionResult Index() { var allPlayers = _playerRepository.GetAllPlayers().ToList().Select(player => new PlayerViewModel { SteamId = player.SteamId, NickName = player.NickName, SteamImage = player.ImagePath, Rang = player.Rang }); var model = new AppStateModel { ApiPaths = Settings.ToJson(), Icons = _strapiApi.GetAllImages()? .Select(icon => new ImageViewModel { Name = icon.CodeName, Image = icon.Image.FullUrl }).ToJson(), Weapons = _strapiApi.GetAllWeapons()? .Select(weapon => new WeaponViewModel { Id = weapon.Id, Name = weapon.Name, IconImage = weapon.Icon.FullUrl, PhotoImage = weapon.Image.FullUrl, Type = weapon.Type.Name }).ToJson(false, true), Players = allPlayers.ToJson() }; return(View(model)); }
Widget _buildCart(BuildContext context, Widget child) { AppStateModel model = ScopedModel <AppStateModel> .of(context); int numProducts = model.productsInCart.Keys.Count; int totalCartQuantity = model.totalCartQuantity; Size screenSize = MediaQuery.of(context).size; float screenWidth = screenSize.width; float screenHeight = screenSize.height; _width = _widthFor(numProducts); _widthAnimation = _getWidthAnimation(screenWidth); _heightAnimation = _getHeightAnimation(screenHeight); _shapeAnimation = _getShapeAnimation(); _thumbnailOpacityAnimation = _getThumbnailOpacityAnimation(); _cartOpacityAnimation = _getCartOpacityAnimation(); return(new Container( width: _widthAnimation.value, height: _heightAnimation.value, child: new Material( animationDuration: TimeSpan.FromMilliseconds(0), shape: new BeveledRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(_shapeAnimation.value) ) ), elevation: 4.0f, color: shrineColorsUtils.kShrinePink50, child: _cartIsVisible ? _buildShoppingCartPage() : _buildThumbnails(numProducts) ) )); }
public void SetCounter(StateContext <AppStateModel> context, SetCounter action) { var state = context.GetState(); state = new AppStateModel(action.Payload, state.SubState); context.SetState(state); }
Product _productWithId(int productId) { AppStateModel model = ScopedModel <AppStateModel> .of(context); Product product = model.getProductById(productId); D.assert(product != null); return(product); }
public override void initState() { base.initState(); this._options = new GalleryOptions( themeMode: ThemeMode.system, textScaleFactor: GalleryTextScaleValue.kAllGalleryTextScaleValues[0], visualDensity: GalleryVisualDensityValue.kAllGalleryVisualDensityValues[0], timeDilation: scheduler_.timeDilation, platform: defaultTargetPlatform ); this.model = new AppStateModel(); this.model.loadProducts(); }
int _calculateOverflow(AppStateModel model) { Dictionary <int, int> productMap = model.productsInCart; List <int> products = productMap.Keys.ToList(); int overflow = 0; int numProducts = products.Count; if (numProducts > 3) { for (int i = 3; i < numProducts; i++) { overflow += productMap[products[i]]; } } return(overflow); }
Widget _buildOverflow(AppStateModel model, BuildContext context) { if (model.productsInCart.Count <= 3) { return(new Container()); } int numOverflowProducts = _calculateOverflow(model); int displayedOverflowProducts = numOverflowProducts <= 99 ? numOverflowProducts : 99; return(new Container( child: new Text( $"+{displayedOverflowProducts}", style: Theme.of(context).primaryTextTheme.button ) )); }
List <Widget> _createShoppingCartRows(AppStateModel model) { List <Widget> widgets = new List <Widget>(); foreach (var product in model.productsInCart.Keys) { int id = product; widgets.Add(new ShoppingCartRow( product: model.getProductById(id), quantity: model.productsInCart[id], onPressed: () => { model.removeItemFromCart(id); } )); } return(widgets); }
public void Test1() { var state = new AppStateModel(2, new SubStateModel(new[] { "name0", "name1", "name2", "name3" })); var store = new Store <AppStateModel>(state); int counter = 0; string name = null; store.Select(new GetCounter()).Subscribe(c => counter = c); store.Select(new GetSubStateName()).Subscribe(n => name = n); Assert.Equal(2, counter); Assert.Equal("name2", name); store.Dispatch(new SetCounter(0)); Assert.Equal(0, counter); Assert.Equal("name0", name); }
public static AppStateModel GetState(AppStateModel state) { return(state); }
public static SubStateModel GetSubState(AppStateModel state) { return(state.SubState); }
public static int GetCounter(AppStateModel state) { return(state.Counter); }
public ShoppingCartSummary(AppStateModel model) { this.model = model; }