Exemplo n.º 1
0
        public OnlineUsersPage(ViewModelBase viewModel)
            : base(viewModel)
        {
            var usersCountLabel = new SquawkLabel () {
            };
            usersCountLabel.SetBinding(Label.TextProperty, new Binding("Users.Count", stringFormat: "     {0} users online"));

            var filterEntry = new SquawkEntry () {
                Placeholder = "Filter...",
            };
            filterEntry.SetBinding (Entry.TextProperty, new Binding ("FilterText"));

            var listView = new BindableListView
                {
                    ItemTemplate = new DataTemplate(() =>
                        {
                            var imageCell = new ImageCell
                                {
                                    ImageSource = Styling.ContactIcon
                                };
                            imageCell.SetBinding(TextCell.TextProperty, new Binding("Name"));
                            imageCell.SetBinding(TextCell.DetailProperty, new Binding("Description"));
                            imageCell.TextColor = Styling.CellTitleColor;
                            imageCell.DetailColor = Styling.CellDetailColor;
                            return imageCell;
                        })
                };

            listView.SetBinding(ListView.ItemsSourceProperty, new Binding("UsersDisplay"));
            listView.SetBinding(BindableListView.ItemClickedCommandProperty, new Binding("SelectUserCommand"));

            var loadingIndicator = new ActivityIndicator ();
            loadingIndicator.SetBinding(ActivityIndicator.IsRunningProperty, new Binding("IsBusy"));
            loadingIndicator.SetBinding(ActivityIndicator.IsVisibleProperty, new Binding("IsBusy"));

            Content = new StackLayout {
                Children = {
                    new StackLayout {Children =
                        {
                            usersCountLabel,
                            filterEntry,
                            loadingIndicator
                        },
                        BackgroundColor = Styling.SubheaderYellow,
                        Padding = new Thickness(3)
                    },
                    listView
                }
            };
        }
Exemplo n.º 2
0
        public ChatPage(ViewModelBase viewModel)
            : base(viewModel)
        {
            SetBinding (ContentPage.TitleProperty, new Binding("RoomName"));
            Icon = Styling.ChatIcon;

            var toolbarItem = new ToolbarItem {
                Text = "Actions",
                Icon = Styling.ToolbarIcon,
                Order = ToolbarItemOrder.Primary
            };
            toolbarItem.SetBinding(ToolbarItem.CommandProperty, new Binding("ContextOptionsCommand"));
            ToolbarItems.Add(toolbarItem);

            var headerLabel = new SquawkLabel();
            headerLabel.FontSize = Styling.Sized(24);
            headerLabel.TextColor = Device.OnPlatform(Color.Green, Color.Yellow, Color.Yellow);
            headerLabel.SetBinding(Label.TextProperty, new Binding("Subject", stringFormat:"  {0}"));

            var sendButton = new Button();
            sendButton.Text = " Send ";
            sendButton.VerticalOptions = LayoutOptions.EndAndExpand;
            sendButton.SetBinding(Button.CommandProperty, new Binding("SendMessageCommand"));
            sendButton.SetBinding(Button.IsEnabledProperty, new Binding("IsInConnectedMode", BindingMode.OneWay));
            if (Device.OS == TargetPlatform.WinPhone)
            {
                sendButton.BackgroundColor = Color.Green;
                sendButton.BorderColor = Color.Green;
                sendButton.TextColor = Color.White;
            }

            var inputBox = new SquawkEntry();
            inputBox.HorizontalOptions = LayoutOptions.FillAndExpand;
            inputBox.Keyboard = Keyboard.Chat;
            inputBox.Placeholder = "Type a message...";
            inputBox.HeightRequest = 30;
            inputBox.SetBinding(Entry.TextProperty, new Binding("InputText", BindingMode.TwoWay));
            inputBox.SetBinding(Entry.IsEnabledProperty, new Binding("IsInConnectedMode", BindingMode.OneWay));

            _messageList = new ChatListView();
            _messageList.VerticalOptions = LayoutOptions.FillAndExpand;
            _messageList.SetBinding(ChatListView.ItemsSourceProperty, new Binding("MessageEvents"));
            _messageList.ItemTemplate = new DataTemplate(CreateMessageCell);
            _messageList.ItemTapped += ItemTapped;
            _messageList.HasUnevenRows = true;
            _messageList.SeparatorVisibility = SeparatorVisibility.None;
            _messageList.SetBinding(Entry.IsEnabledProperty, new Binding("IsInRequestMode", BindingMode.OneWay, converter: new InverterConverter()));

            var typingLabel = new SquawkLabel();
            typingLabel.FontSize = Styling.Sized(11);
            typingLabel.TextColor = Color.Gray;
            typingLabel.SetBinding(Label.TextProperty, new Binding("TypingEventsString", stringFormat:"  {0}"));
            //typingLabel.SetBinding(Label.IsVisibleProperty, new Binding("AreTypingEvents"));

            #region Error Message UI
            var chatStatusLabel = new SquawkLabel {
                HorizontalOptions = LayoutOptions.Center,
                FontSize = 16,
                TextColor = Color.Gray
            };

            chatStatusLabel.SetBinding(Label.TextProperty, new Binding("StatusText", BindingMode.OneWay));
            var chatStatusLayout = new StackLayout
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children =
                {
                    chatStatusLabel
                }
            };
            chatStatusLayout.SetBinding(StackLayout.IsVisibleProperty, new Binding("IsInMessageMode", BindingMode.OneWay));
            #endregion

            #region Request UI
            var requestLabel = new SquawkLabel {
                HorizontalOptions = LayoutOptions.Center,
                FontSize = Styling.Sized(16),
                Text = "This user wants to chat!  What would you like to do?"
            };

            var acceptButton = new Button(){
                FontSize = Styling.Sized(14)
            };
            acceptButton.Text = "Accept";
            acceptButton.SetBinding(Button.CommandProperty, new Binding("AcceptChatCommand"));
            if (Device.OS == TargetPlatform.WinPhone)
            {
                acceptButton.BackgroundColor = Color.Green;
                acceptButton.BorderColor = Color.Green;
                acceptButton.TextColor = Color.White;
            }

            var declineButton = new Button(){
                FontSize = Styling.Sized(14)
            };
            declineButton.Text = "Decline";
            declineButton.SetBinding(Button.CommandProperty, new Binding("DeclineChatCommand"));
            if (Device.OS == TargetPlatform.WinPhone)
            {
                declineButton.BackgroundColor = Color.Green;
                declineButton.BorderColor = Color.Green;
                declineButton.TextColor = Color.White;
            }

            var ignoreButton = new Button();
            {
                ignoreButton.FontSize = Styling.Sized(14);
                ignoreButton.Text = "Ignore";
                ignoreButton.SetBinding(Button.CommandProperty, new Binding("LeaveRoomCommand"));
                if (Device.OS == TargetPlatform.WinPhone)
                {
                    ignoreButton.BackgroundColor = Color.Green;
                    ignoreButton.BorderColor = Color.Green;
                    ignoreButton.TextColor = Color.White;
                }
            }

            var requestLayout = new StackLayout
            {
                VerticalOptions = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Spacing = 15,
                Children =
                {
                    requestLabel,
                    acceptButton,
                    declineButton,
                    ignoreButton
                }
            };
            requestLayout.SetBinding(StackLayout.IsVisibleProperty, new Binding("IsInRequestMode", BindingMode.OneWay));
            #endregion

            Content  = new StackLayout
            {
                Padding = Device.OnPlatform(new Thickness(6,6,6,6), new Thickness(0), new Thickness(0)),
                Children =
                {
                    _messageList,
                    chatStatusLayout,
                    requestLayout,
                    typingLabel,
                    new StackLayout
                    {

                        Children = {inputBox, sendButton},
                        Orientation = StackOrientation.Horizontal,
                        Padding = new Thickness(0, Device.OnPlatform(0, 20, 0),0,0),
                        //VerticalOptions = LayoutOptions.End
                    }
                }
            };
        }
Exemplo n.º 3
0
        public LoginPage(ViewModelBase viewModel)
            : base(viewModel)
        {
            BackgroundColor = Styling.BackgroundYellow;
            var fs = new FormattedString () {
                Spans = {
                    new Span{ Text = "Shared", FontSize = 32, FontAttributes = FontAttributes.None },
                    new Span{ Text = "Squawk", FontSize = 32, FontAttributes = FontAttributes.Bold },
                }
            };

            var header = new SquawkLabel
            {
                FormattedText = fs,
                HorizontalOptions = LayoutOptions.Center,
                TextColor = Styling.BlackText
            };

            var loginButton = new Button();
            loginButton.Text = "Login";
            loginButton.SetBinding(IsEnabledProperty, new Binding("IsBusy", converter: new InverterConverter()));
            loginButton.SetBinding(Button.CommandProperty, new Binding("LoginCommand"));
            loginButton.FontSize = 24;

            var registerButton = new Button();
            registerButton.FontAttributes = FontAttributes.Italic;
            registerButton.Text = "Don't have an account?";
            registerButton.SetBinding(Button.CommandProperty, new Binding("RegisterCommand"));
            registerButton.FontSize = 12;

            var nameEntry = new SquawkEntry
            {
                Keyboard = Keyboard.Text,
                Placeholder = "Username",
            };
            nameEntry.SetBinding(Entry.TextProperty, new Binding("Name", BindingMode.TwoWay));

            var passwordEntry = new SquawkEntry
            {
                Keyboard = Keyboard.Text,
                IsPassword = true,
                Placeholder = "Password",
            };
            passwordEntry.SetBinding(Entry.TextProperty, new Binding("Password", BindingMode.TwoWay));

            // Accomodate iPhone status bar.
            Padding = new Thickness(10, Device.OnPlatform(iOS: 20, Android: 0, WinPhone: 0), 10, 100);

            var loadingIndicator = new ActivityIndicator ();
            loadingIndicator.SetBinding(ActivityIndicator.IsRunningProperty, new Binding("IsBusy"));
            loadingIndicator.SetBinding(ActivityIndicator.IsVisibleProperty, new Binding("IsBusy"));

            Content = new StackLayout
            {
                Children =
                {
                    header,
                    new StackLayout
                    {
                        Children =
                        {
                            nameEntry,
                            passwordEntry
                        }
                    },
                    loadingIndicator,
                    loginButton,
                    registerButton
                },
                VerticalOptions = LayoutOptions.Center,
                Spacing = 30,
                Padding = new Thickness(25, 80, 25, 0)
            };
        }