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));
        }
Esempio n. 2
0
        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)
                           )
                       ));
        }
Esempio n. 3
0
        public void SetCounter(StateContext <AppStateModel> context, SetCounter action)
        {
            var state = context.GetState();

            state = new AppStateModel(action.Payload, state.SubState);
            context.SetState(state);
        }
Esempio n. 4
0
        Product _productWithId(int productId)
        {
            AppStateModel model = ScopedModel <AppStateModel> .of(context);

            Product product = model.getProductById(productId);

            D.assert(product != null);
            return(product);
        }
Esempio n. 5
0
 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();
 }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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
                           )
                       ));
        }
Esempio n. 8
0
        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);
        }
Esempio n. 10
0
 public static AppStateModel GetState(AppStateModel state)
 {
     return(state);
 }
Esempio n. 11
0
 public static SubStateModel GetSubState(AppStateModel state)
 {
     return(state.SubState);
 }
Esempio n. 12
0
 public static int GetCounter(AppStateModel state)
 {
     return(state.Counter);
 }
Esempio n. 13
0
 public ShoppingCartSummary(AppStateModel model)
 {
     this.model = model;
 }