Example #1
0
 void CreateView()
 {
     grid = new GridWithSelectedImageString();
     UIBuilder.BuildProfilePicGrid(grid, new string[] { "brownhairblackcollarmale.png", "brownhaircaucasian.png", "orangeeyes.png", "stormtrooper.png" });
     this.BackgroundColor = Color.FromHex(Values.BACKGROUNDLIGHTSILVER);
     Content = new StackLayout {
         BackgroundColor = Color.White,
         Padding         = new Thickness(20),
         Children        =
         {
             new Label      {
                 Text = "Choose an anonymous profile pic!",
                 HorizontalTextAlignment = TextAlignment.Center,
                 HorizontalOptions       = LayoutOptions.Center,
                 FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
             },
             new Label      {
                 Text = "To keep Secret Files and its community anonymous, we don't allow users to upload profile pictures. \nHave fun choosing a Secret Face!",
                 HorizontalTextAlignment = TextAlignment.Center,
                 HorizontalOptions       = LayoutOptions.Center,
                 FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label))
             },
             new ScrollView {
                 Content = grid
             }
         }
     };
 }
Example #2
0
        public static void BuildGroupPicGrid(GridWithSelectedImageString grid, string[] pics)
        {
            if (grid == null)
            {
                return;
            }

            if (pics.Length <= 0 || pics == null)
            {
                return;
            }

            for (int c = 0; c < pics.Length; c++)
            {
                grid.Children.AddHorizontal(UIBuilder.CreateTappableGroupImage(grid, pics [c]));
            }
        }
Example #3
0
 public static async Task ChangeGroupPic(GridWithSelectedImageString grid, Image img)
 {
     try{
         string newprofilepic = GetImagePathFromImage(img);
         if (!string.IsNullOrWhiteSpace(newprofilepic))
         {
             //GroupItem.groupImage = Util.FromPickerIconChooseProfileIcon (newprofilepic);
             grid.StringImageSelected = newprofilepic;                    //Util.FromPickerIconChooseProfileIcon(newprofilepic);
             Debug.WriteLine("New group pic is {0}", grid.StringImageSelected);
             UserDialogs.Instance.ShowSuccess("Group picture changed!", 2000);
         }
         else
         {
             UserDialogs.Instance.WarnToast("Oops, something went wrong, pls try again!", null, 2000);
         }
     }catch (Exception e) {
         Debug.WriteLine("Problem changing group pic: " + e.Message);
         UserDialogs.Instance.WarnToast("Oops, something went wrong, pls try again!", null, 2000);
     }
 }
Example #4
0
        public static Image CreateTappableGroupImage(GridWithSelectedImageString grid, string source, Command TapAction = null)
        {
            Image img = new Image {
                Aspect = Aspect.AspectFit,
                Source = source
            };

            if (TapAction != null)
            {
                img.GestureRecognizers.Add(new TapGestureRecognizer {
                    Command = TapAction
                });
            }
            else
            {
                img.GestureRecognizers.Add(new TapGestureRecognizer {
                    Command = new Command(() => Util.ChangeGroupPic(grid, img))
                });
            }
            return(img);
        }
Example #5
0
        void CreateUI()
        {
            grid = new GridWithSelectedImageString();
            UIBuilder.BuildGroupPicGrid(grid, new string[] { "ic_cake_amber_500_24dp.png", "ic_cake_blue_700_24dp.png", "ic_cake_deep_orange_700_24dp.png", "ic_cake_green_600_24dp.png", "ic_cake_pink_400_24dp.png" });           //add images
            Debug.WriteLine("{0} elements in grid", grid.Children.Count);

            this.BackgroundColor = Color.White;

            img = new Image {
                Source            = "ic_camera_alt_grey_500_24dp.png",
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            };

            tapHandler = new TapGestureRecognizer {
                NumberOfTapsRequired = 1
            };
            tapHandler.Tapped += async(sender, e) => {
                var file = await App.Camera.ChooseImage(this);

                if (!string.IsNullOrEmpty(file))
                {
                    img.Source = file;
                    //upload to cloud
                }
            };
            img.GestureRecognizers.Add(tapHandler);

            desc = new Editor {
                Text = "Enter something to tell your followers what this secret file is for...",
                HorizontalOptions = LayoutOptions.CenterAndExpand
                                    //TextColor = Color.Silver
            };
            desc.Focused += (sender, e) => {
                if (string.Equals(desc.Text, "Enter something to tell your followers what this secret file is for..."))
                {
                    desc.Text = "";
                }
            };
            desc.Unfocused += (sender, e) => {
                if (string.IsNullOrWhiteSpace(desc.Text))
                {
                    desc.Text = "Enter something to tell your followers what this secret file is for...";
                }
            };

            groupNameEntry = new Entry {
                Text              = "What do you want to call this secret file?",
                TextColor         = Color.Silver,
                Keyboard          = Keyboard.Create(KeyboardFlags.All),
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            };
            groupNameEntry.Focused += (sender, e) => {
                if (string.Equals(groupNameEntry.Text, "What do you want to call this secret file?"))
                {
                    groupNameEntry.Text = "";
                }
                groupNameEntry.TextColor = Color.Default;
            };
            groupNameEntry.Unfocused += (sender, e) => {
                if (string.IsNullOrWhiteSpace(groupNameEntry.Text))
                {
                    groupNameEntry.Text      = "What do you want to call this secret file?";
                    groupNameEntry.TextColor = Color.Silver;
                }
            };
            groupNameEntry.Focus();

            Done = new ToolbarItem("Done", "ic_done_white_24dp.png", async() => {
                //save to table
                if (string.IsNullOrWhiteSpace(groupNameEntry.Text))
                {
                    UserDialogs.Instance.WarnToast("Oops! Can't make a secret file without a name!", null, 2000);
                }
                else if (string.IsNullOrWhiteSpace(grid.StringImageSelected))
                {
                    UserDialogs.Instance.WarnToast("Please don't forget to choose a secret file picture", null, 2000);
                }
                else
                {
                    if (!RegexHelper.MatchesOfficialSecretFilesThreadName(groupNameEntry.Text))
                    {
                        await App.DataDB.SaveGroupsItemsTaskAsync(new GroupItem {
                            groupName = groupNameEntry.Text,
                            groupDesc = desc.Text, adminuserID = Settings.UserId, groupImage = grid.StringImageSelected
                        });
                        Util.NewGroupNotif(this);
                        await Navigation.PopAsync();
                    }
                    else
                    {
                        await this.DisplayAlert("A Secret File with that name already exists", "To avoid confusion we don't allow new threads named 'Secret Files' or anything similar. Please think of a different name", "OK");
                    }
                }
            });
            Cancel = new ToolbarItem("Cancel", "ic_clear_white_24dp.png", () => {
                Navigation.PopAsync();
            });
            this.ToolbarItems.Add(Done);
            //this.ToolbarItems.Add (Cancel);

            Content = new StackLayout {
                Orientation = StackOrientation.Vertical,
                Padding     = new Thickness(20),
                Children    =
                {
                    //img, no option to upload custom pics yet. minimize server costs
                    new StackLayout   {
                        Orientation = StackOrientation.Vertical,
                        Children    =
                        {
                            new Label {
                                Text = "Choose a Secret Files Pic",
                                HorizontalTextAlignment = TextAlignment.Center,
                                HorizontalOptions       = LayoutOptions.Center,
                                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
                            },

                            /*new Label{
                             *      Text = "To keep Secret Files and its community anonymous, we don't allow users to upload profile pictures. So have fun choosing your new face!",
                             *      HorizontalTextAlignment = TextAlignment.Center,
                             *      HorizontalOptions = LayoutOptions.Center,
                             *      FontSize = Device.GetNamedSize (NamedSize.Small, typeof(Label))
                             * },*/
                            UIBuilder.CreateSeparatorWithTopBottomSpacing(Color.Gray, 0.5),
                            grid,
                            UIBuilder.CreateWhiteSpacing(10),
                        }
                    },
                    new StackLayout   {
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.Center,
                        Children          = { groupNameEntry }
                    }, desc
                }
            };
        }