public async override void OnAppear() { base.OnAppear(); await CheckBusy(async() => { await LoadingPopup.Instance.Show(TranslateExtension.Get("Loading3dot")); var url = ApiUrl.GetWallet() + UserInfo.WalletAddress; var response = await HttpRequest.GetTaskAsync <ModelRestFul>(url); await GetWalletCallBack(response); }); }
public CategoryPageViewModel(INavigationService navigationService, ISqLiteService sqLiteService) : base(navigationService: navigationService, sqliteService: sqLiteService) { IsSearchCommand = new DelegateCommand(IsSearchChangeExcute); SelectedCategoryCommand = new DelegateCommand(SelectedCategoryExcute); var list = SqLiteService.GetList <Category>(x => x.Id != -1).ToList(); if (list.Count > 0) { CategoryList = new ObservableCollection <Category>(list); } else { CategoryList = new ObservableCollection <Category>() { new Category() { Id = 1, CategoryName = TranslateExtension.Get("ElectronicsAndGadgets"), Image = "ic_history", }, new Category() { Id = 2, CategoryName = TranslateExtension.Get("HomeAndFurniture"), Image = "ic_history", }, new Category() { Id = 3, CategoryName = TranslateExtension.Get("SportAndHealth"), Image = "ic_history", }, new Category() { Id = 4, CategoryName = TranslateExtension.Get("Fashion"), Image = "ic_history", }, new Category() { Id = 5, CategoryName = TranslateExtension.Get("OfficeAndIndustry"), Image = "ic_history", } }; foreach (var item in CategoryList) { SqLiteService.Insert(item); } } }
private async Task GetWalletCallBack(ModelRestFul response) { if (response == null) { await MessagePopup.Instance.Show(TranslateExtension.Get("Fail")); return; } else { Serializer serializer = new Serializer(); var a = response.Result.ToString(); var b = serializer.Deserialize <ModelTestApi>(a); if (b != null) { AmountCoin = b.Amount; } } await LoadingPopup.Instance.Hide(); }
public async Task Show(string loadingMessage = null) { await DeviceExtension.BeginInvokeOnMainThreadAsync(() => { LabelMessage.Text = !string.IsNullOrWhiteSpace(loadingMessage) ? loadingMessage : TranslateExtension.Get("Loading"); }); if (IsLoading) { return; } IsLoading = true; await DeviceExtension.BeginInvokeOnMainThreadAsync(async() => { Indicator.IsRunning = true; await Application.Current.MainPage.Navigation.PushPopupAsync(this); }); }
public ProceedToCheckoutPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, ISqLiteService sqLiteService, IHttpRequest httpRequest) : base(navigationService: navigationService, dialogService: pageDialogService, sqliteService: sqLiteService, httpRequest: httpRequest) { NavigateToWalletCommand = new DelegateCommand(NavigateToWalletExcute); if (!IsNullCart) { var listItemOfCartTemp = SqLiteService.GetList <OrderDetails>(x => x.Id != ""); ItemOfOrder = new ObservableCollection <OrderDetails>(); if (listItemOfCartTemp != null) { ItemOfOrder = new ObservableCollection <OrderDetails>(listItemOfCartTemp); foreach (var item in ItemOfOrder) { Total += item.Amount * item.Price; } } } ChooseShippingList = new ObservableCollection <string>() { TranslateExtension.Get("FreeShip"), TranslateExtension.Get("Standard"), TranslateExtension.Get("Express"), }; ChooseScheduleWay = new ObservableCollection <string>() { TranslateExtension.Get("Once"), TranslateExtension.Get("Twice"), TranslateExtension.Get("Third"), }; CheckoutCommand = new DelegateCommand(CheckoutExcute); if (App.Settings.IsLogin) { UserInfo = SqLiteService.Get <UserModel>(x => x.Id != -1); } }
protected override void OnStart() { base.OnStart(); CrossFirebasePushNotification.Current.Subscribe("general"); CrossFirebasePushNotification.Current.OnTokenRefresh += (s, p) => { System.Diagnostics.Debug.WriteLine($"TOKEN REC: {p.Token}"); }; System.Diagnostics.Debug.WriteLine($"TOKEN: {CrossFirebasePushNotification.Current.Token}"); CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) => { try { System.Diagnostics.Debug.WriteLine("Received"); var noti = new NotificationModel(); if (p.Data.ContainsKey("body")) { Device.BeginInvokeOnMainThread(() => { p.Data["title"] = TranslateExtension.Get(p.Data["TitleKey"].ToString()); noti.Title = p.Data["title"].ToString(); if (p.Data.ContainsKey("Coin")) { if (p.Data.ContainsKey("ProductName")) { p.Data["body"] = string.Format(TranslateExtension.Get(p.Data["MessageKey"].ToString()), p.Data["Coin"].ToString(), p.Data["ProductName"].ToString()); } else { p.Data["body"] = string.Format(TranslateExtension.Get(p.Data["MessageKey"].ToString()), p.Data["Coin"].ToString()); } noti.Message = p.Data["body"].ToString(); } else { p.Data["body"] = TranslateExtension.Get(p.Data["MessageKey"].ToString()); noti.Message = p.Data["body"].ToString(); } //noti.Title = p.Data["title"].ToString(); if (p.Data.ContainsKey("DateTimeSend")) { noti.DateTimeSend = double.Parse(p.Data["DateTimeSend"].ToString()); } noti.Time = p.Data["Time"].ToString(); _sqLiteService.Insert(noti); }); } } catch (Exception ex) { } }; CrossFirebasePushNotification.Current.OnNotificationOpened += (s, p) => { //System.Diagnostics.Debug.WriteLine(p.Identifier); System.Diagnostics.Debug.WriteLine("Opened"); foreach (var data in p.Data) { System.Diagnostics.Debug.WriteLine($"{data.Key} : {data.Value}"); } if (p.Data.ContainsKey("aps.alert.title")) { Device.BeginInvokeOnMainThread(() => { System.Diagnostics.Debug.WriteLine($"{p.Data["aps.alert.title"]}"); }); } }; CrossFirebasePushNotification.Current.OnNotificationAction += (s, p) => { System.Diagnostics.Debug.WriteLine("Action"); if (!string.IsNullOrEmpty(p.Identifier)) { System.Diagnostics.Debug.WriteLine($"ActionId: {p.Identifier}"); foreach (var data in p.Data) { System.Diagnostics.Debug.WriteLine($"{data.Key} : {data.Value}"); } } }; CrossFirebasePushNotification.Current.OnNotificationDeleted += (s, p) => { System.Diagnostics.Debug.WriteLine("Dismissed"); }; }
private void LoadItem(ObservableCollection <OrderDetails> list) { var vm = (ShowCardPageViewModel)BindingContext; listItem.Children.Clear(); foreach (var item in list) { var frame = new Frame() { Margin = new Thickness(0, 5) }; var grid = new Grid(); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); var image = new CachedImage() { Source = item.Image, Aspect = Aspect.AspectFill, HeightRequest = 80, WidthRequest = 80, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; grid.Children.Add(image, 0, 0); var stack = new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, Orientation = StackOrientation.Vertical, Padding = new Thickness(25, 5, 10, 5), }; //Name var labelName = new Label() { Text = item.Name, FontSize = (double)App.Current.Resources["LargeLabelFont"], TextColor = (Color)App.Current.Resources["SDarkerTextColor"], }; //Manufacter var labelManu = new Label() { Text = item.Manufacturer, FontSize = (double)App.Current.Resources["NormalLabelFont"], TextColor = (Color)App.Current.Resources["Purple"], }; //Price CultureInfo cul = CultureInfo.GetCultureInfo("vi-VN"); // try with "en-US" string a = double.Parse(item.Price.ToString()).ToString("#,###", cul.NumberFormat); a += "đ"; var stackPrice = new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, Orientation = StackOrientation.Horizontal, }; var labelPrice = new Label() { Text = item.Price.ToString(), FontSize = (double)App.Current.Resources["LargeLabelFont"], TextColor = (Color)App.Current.Resources["Blue"], VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Start, }; var imagePrice = new Image() { Source = "ic_coin", VerticalOptions = LayoutOptions.CenterAndExpand, HeightRequest = 25, WidthRequest = 25, }; stackPrice.Children.Add(labelPrice); stackPrice.Children.Add(imagePrice); //Quantity var labelQuantity = new Label() { Text = TranslateExtension.Get("Quantity"), FontSize = (double)App.Current.Resources["NormalLabelFont"], TextColor = (Color)App.Current.Resources["SDarkerTextColor"], VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Start, }; var labelAmount = new Label() { Text = item.Amount.ToString(), FontSize = (double)App.Current.Resources["NormalLabelFont"], TextColor = (Color)App.Current.Resources["SDarkerTextColor"], VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Start, }; var stackQuantity = new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, Orientation = StackOrientation.Horizontal, }; stackQuantity.Children.Add(labelQuantity); stackQuantity.Children.Add(labelAmount); var stackControl = new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, Orientation = StackOrientation.Horizontal, Spacing = 0, }; var button = new BorderButton() { Text = TranslateExtension.Get("Delete"), Theme = Enums.BorderButtonTheme.RedWhite, TextColor = Color.FromHex("#D50000"), FontSize = 16, Padding = new Thickness(0, 0, 0, 0), CornerRadius = 0, HorizontalOptions = LayoutOptions.EndAndExpand, ClassId = item.Id, VerticalOptions = LayoutOptions.CenterAndExpand, }; button.Clicked += (s, e) => { foreach (var item1 in list) { if (item1.Id == button.ClassId) { vm?.DeleteItemOfOrder(item1.Id); OnAppearing(); break; } } }; var labelItems = new Label() { Text = TranslateExtension.Get("Items"), FontSize = (double)App.Current.Resources["NormalLabelFont"], TextColor = (Color)App.Current.Resources["SDarkerTextColor"], VerticalOptions = LayoutOptions.CenterAndExpand, Margin = new Thickness(0, 0, 0, 0), HorizontalOptions = LayoutOptions.StartAndExpand, }; var entryEditQuantity = new Entry() { Text = item.Amount.ToString(), HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, FontSize = (double)App.Current.Resources["NormalLabelFont"], Keyboard = Keyboard.Numeric, Margin = new Thickness(0, 0, 0, 0) }; entryEditQuantity.TextChanged += (s, e) => { if (!string.IsNullOrEmpty(entryEditQuantity.Text)) { foreach (var item1 in list) { if (item1.Id == button.ClassId) { var newAmount = Int32.Parse(entryEditQuantity.Text); vm?.EditQuantityItemOfOrder(item1.Id, newAmount); labelAmount.Text = entryEditQuantity.Text; break; } } } }; stackControl.Children.Add(entryEditQuantity); stackControl.Children.Add(labelItems); stackControl.Children.Add(button); stack.Children.Add(labelName); stack.Children.Add(labelManu); stack.Children.Add(stackPrice); stack.Children.Add(stackQuantity); stack.Children.Add(stackControl); grid.Children.Add(image, 0, 0); grid.Children.Add(stack, 1, 0); frame.Content = grid; listItem.Children.Add(frame); } }
private void LoadItem(ObservableCollection <OrderDetails> list) { var vm = (ProceedToCheckoutPageViewModel)BindingContext; listItem.Children.Clear(); foreach (var item in list) { var frame = new Frame() { Margin = new Thickness(0, 5) }; var grid = new Grid(); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); var image = new CachedImage() { Source = item.Image, Aspect = Aspect.AspectFill, HeightRequest = 80, WidthRequest = 80, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; grid.Children.Add(image, 0, 0); var stack = new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, Orientation = StackOrientation.Vertical, Padding = new Thickness(25, 5, 10, 5), }; //Name var labelName = new Label() { Text = item.Name, FontSize = (double)App.Current.Resources["LargeLabelFont"], TextColor = (Color)App.Current.Resources["SDarkerTextColor"], }; //Manufacter var labelManu = new Label() { Text = item.Manufacturer, FontSize = (double)App.Current.Resources["NormalLabelFont"], TextColor = (Color)App.Current.Resources["Purple"], }; //Price //CultureInfo cul = CultureInfo.GetCultureInfo("vi-VN"); // try with "en-US" //string a = double.Parse(item.Price.ToString()).ToString("#,###", cul.NumberFormat); // a += "đ"; var stackPrice = new StackLayout() { Orientation = StackOrientation.Horizontal, }; var labelPrice = new Label() { Text = item.Price.ToString(), FontSize = (double)App.Current.Resources["LargeLabelFont"], TextColor = (Color)App.Current.Resources["Blue"], VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Start, }; var imageCoin = new Image() { Source = "ic_coin", WidthRequest = 25, HeightRequest = 25, }; stackPrice.Children.Add(labelPrice); stackPrice.Children.Add(imageCoin); //Quantity var labelQuantity = new Label() { Text = TranslateExtension.Get("Quantity"), FontSize = (double)App.Current.Resources["NormalLabelFont"], TextColor = (Color)App.Current.Resources["SDarkerTextColor"], VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Start, }; var labelAmount = new Label() { Text = item.Amount.ToString(), FontSize = (double)App.Current.Resources["NormalLabelFont"], TextColor = (Color)App.Current.Resources["SDarkerTextColor"], VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Start, }; var stackQuantity = new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, Orientation = StackOrientation.Horizontal, }; stackQuantity.Children.Add(labelQuantity); stackQuantity.Children.Add(labelAmount); stack.Children.Add(labelName); stack.Children.Add(labelManu); stack.Children.Add(stackPrice); stack.Children.Add(stackQuantity); grid.Children.Add(image, 0, 0); grid.Children.Add(stack, 1, 0); frame.Content = grid; listItem.Children.Add(frame); } }