Exemplo n.º 1
0
        public void Handle_OnScanResult(Result result)
        {
            Device.BeginInvokeOnMainThread(async() =>
            {
                try
                {
                    await Navigation.PopAsync();
                    await DisplayAlert("Welcome!", $"You have successfully joined the group", "Thanks");


                    var oauthToken = await SecureStorage.GetAsync("oauth_token");
                    var person     = await db.GetPerson(oauthToken);

                    var _person = person.Key;
                    var _name   = person.FullName;

                    //All Conversations


                    await db.joinConversation2(result.Text, _person, _name);



                    //foreach (var group in list)
                    //{
                    //    if(result.Text != group.Name)
                    //    {
                    //        await DisplayAlert("Oops", "We couldn't find a group", "Try Again");
                    //    } else
                    //    {
                    //        await db.joinConversation2(result.Text, _person, _name);
                    //        await Navigation.PopAsync(true);
                    //    }
                    //}
                }
                catch
                {
                    await DisplayAlert("Oops", "We couldn't find a group", "Try Again");
                }
            });
        }
Exemplo n.º 2
0
        public async void Handle_Clicked(object sender, System.EventArgs e)
        {
            var oauthToken = await SecureStorage.GetAsync("oauth_token");

            var person = await db.GetPerson(oauthToken);

            if (_etMessage.Text != "")
            {
                var chatOBJ = new Model.Chat {
                    UserMessage = _etMessage.Text, UserId = person.FullName
                };

                await db.saveMessage(chatOBJ, rm.Key);

                _etMessage.Text = string.Empty;
            }
            else
            {
                Console.WriteLine("Empty Message");
            }
        }
Exemplo n.º 3
0
        public async void Handle_Clicked(object sender, System.EventArgs e)
        {
            if (_rootName.Text == "" || iconSelected == "")
            {
                await DisplayAlert("Oops", "You need to choose a Name and an Icon", "Try Again");
            }
            else
            {
                var db = new Database.Firebase();
                Console.WriteLine(iconSelected);
                await db.createConversation(new Model.Conversation()
                {
                    Name = _rootName.Text, Icon = iconSelected
                });

                var oauthToken = await SecureStorage.GetAsync("oauth_token");

                var person = await db.GetPerson(oauthToken);

                var _person = person.Key;
                var _name   = person.FullName;

                //All Conversations
                var list = await db.getConversationList();


                //For loop to add the logged in users conversations into the second list
                foreach (Model.Conversation conversation in list)
                {
                    if (conversation.Name == _rootName.Text)
                    {
                        await db.joinConversation2(conversation.Key, _person, _name);

                        await Navigation.PopAsync();
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            //Check Logged In User
            var loggedIn = await SecureStorage.GetAsync("loggedIn");

            if (loggedIn == "true")
            {
                //All Conversations
                var list = await db.getConversationList();


                //observableList.BindingContext = db.subConvos();



                //Logged in User's key
                var loggedInPerson = await SecureStorage.GetAsync("oauth_token");

                var person = await db.GetPerson(loggedInPerson);

                var personKey  = person.Key;
                var personAuth = person.Role;

                //Second List
                List <Model.Conversation> list2 = new List <Model.Conversation>();



                //For loop to add the logged in users conversations into the second list
                foreach (Model.Conversation conversation in list)
                {
                    var users = await fbClient.Child("Conversation").Child(conversation.Key).Child("Users").OnceAsync <Model.JoinedChat>();

                    foreach (var user in users)
                    {
                        if (user.Object.PersonId == personKey)
                        {
                            list2.Add(conversation);

                            //var observable = fbClient
                            //    .Child("Conversation")
                            //  .Child("Conversation/" + conversation.Key + "/Message")
                            //  .AsObservable<Model.Conversation>()
                            //  .Subscribe(convo =>
                            //  {
                            //      observableList.Add(convo.Object);
                            //      Console.WriteLine(convo.Object.Name);
                            //});
                        }
                    }
                }

                //Bind list

                _lstx.BindingContext = list2;

                conversatoinIndicator.IsVisible = false;
                conversatoinIndicator.IsRunning = false;

                if (list2.Count == 0)
                {
                    NoChats.IsVisible = true;
                }
                else
                {
                    NoChats.IsVisible = false;
                }

                //Check Role to show create Button
                if (personAuth == "Admin")
                {
                    CreateButton.IsVisible = true;
                    ScanButton.IsVisible   = true;
                }
                else
                {
                    CreateButton.IsVisible = false;
                    ScanButton.IsVisible   = true;
                }
            }
            else
            {
                await Navigation.PopToRootAsync();
            }
        }