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 } }; }
public InviteToAppPage(ViewModelBase viewModel) : base(viewModel) { Title = "Contacts"; var contactsCountLabel = new SquawkLabel(); contactsCountLabel.SetBinding(Label.TextProperty, new Binding("Contacts.Count", stringFormat: "{0} contacts.")); var tipLabel = new SquawkLabel(); tipLabel.Text = "Select a contact to send an invitation"; var listView = new BindableListView { ItemTemplate = new DataTemplate(() => { var imageCell = new ImageCell { ImageSource = Device.OnPlatform( ImageSource.FromFile("empty_contact.jpg"), ImageSource.FromFile("empty_contact.jpg"), ImageSource.FromFile("Assets/empty_contact.jpg")), }; imageCell.SetBinding(TextCell.TextProperty, new Binding("Name")); imageCell.SetBinding(TextCell.DetailProperty, new Binding("Number")); return imageCell; }), IsGroupingEnabled = true, GroupDisplayBinding = new Binding("Name"), }; listView.SetBinding(ListView.ItemsSourceProperty, new Binding("GroupedContacts")); listView.SetBinding(BindableListView.ItemClickedCommandProperty, new Binding("ContactSelectedCommand")); var loadingIndicator = new ActivityIndicator(); loadingIndicator.SetBinding(ActivityIndicator.IsRunningProperty, new Binding("IsBusy")); Content = new StackLayout { Children = { loadingIndicator, contactsCountLabel, tipLabel, listView } }; }
public RegistrationPage(ViewModelBase viewModel) : base(viewModel) { var countryPicker = new BindablePicker(); countryPicker.Title = "Country"; countryPicker.SetBinding(BindablePicker.ItemsSourceProperty, new Binding("Countries")); countryPicker.SetBinding(BindablePicker.SelectedItemProperty, new Binding("SelectedCountry", BindingMode.TwoWay)); var sexPicker = new BindablePicker(); sexPicker.Title = "Sex"; sexPicker.SetBinding(BindablePicker.ItemsSourceProperty, new Binding("Sexes")); sexPicker.SetBinding(BindablePicker.SelectedItemProperty, new Binding("SelectedSex", BindingMode.TwoWay)); var agePicker = new BindablePicker(); agePicker.Title = "Age"; agePicker.SetBinding(BindablePicker.ItemsSourceProperty, new Binding("Ages")); agePicker.SetBinding(BindablePicker.SelectedItemProperty, new Binding("SelectedAge", BindingMode.TwoWay)); var header = new SquawkLabel { Text = "Registration", FontSize = 36, HorizontalOptions = LayoutOptions.Center }; var button = new Button(); button.Text = "Register"; button.SetBinding(IsEnabledProperty, new Binding("IsBusy", converter: new InverterConverter())); button.SetBinding(Button.CommandProperty, new Binding("RegisterCommand")); button.BackgroundColor = Color.Green; button.TextColor = Color.White; var nameEntry = new Entry { Keyboard = Keyboard.Text, Placeholder = "Nickname", }; nameEntry.SetBinding(Entry.TextProperty, new Binding("Name", BindingMode.TwoWay)); var passwordEntry = new Entry { 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, 5); Content = new StackLayout { Children = { header, nameEntry, passwordEntry, countryPicker, sexPicker, agePicker, button } }; }
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 } } }; }
private Cell CreateMessageCell() { var timestampLabel = new SquawkLabel(); timestampLabel.SetBinding(SquawkLabel.TextProperty, new Binding("Timestamp", stringFormat: "[{0:HH:mm}]")); timestampLabel.TextColor = Styling.CellDetailColor; timestampLabel.FontSize = 14; var authorLabel = new SquawkLabel(); authorLabel.SetBinding(SquawkLabel.TextProperty, new Binding("AuthorName", stringFormat: "{0}: ")); authorLabel.TextColor = Device.OnPlatform(Color.White, Color.Yellow, Color.Yellow); authorLabel.FontSize = 14; var messageLabel = new SquawkLabel(); messageLabel.SetBinding(SquawkLabel.TextProperty, new Binding("Text")); messageLabel.FontSize = 14; var stack = new StackLayout { Orientation = StackOrientation.Horizontal, Children = {authorLabel, messageLabel} }; if (Device.Idiom == TargetIdiom.Tablet) { stack.Children.Insert(0, timestampLabel); } var view = new MessageViewCell { View = stack }; return view; }
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) }; }
public SettingsPage(ViewModelBase viewModel) : base(viewModel) { var aboutLabel = new SquawkLabel() { HorizontalOptions = LayoutOptions.Center, FontSize = Styling.Sized(14), Text = "SharedSquawk is an app to practice your language skills and meet users " + "all over the world. Talk with people from the www.SharedTalk.com community. " + "\n\nThis app has no affiliation with Rosetta Stone or the www.SharedTalk.com website.\n\n" + "It is open source and can be contributed to at www.github.com/alexnaraghi/SharedSquawk", TextColor = Color.Gray }; var separator = new BoxView () { Color = Color.Gray, HeightRequest = 1 }; var userLabel = new SquawkLabel() { HorizontalOptions = LayoutOptions.Center, FontSize = Styling.Sized(18) }; userLabel.SetBinding(Label.TextProperty, new Binding("User")); var profileButton = new Button(){ FontSize = Styling.Sized (18) }; profileButton.Text = "Profile"; profileButton.SetBinding(Button.CommandProperty, new Binding("ViewProfileCommand")); var logoutButton = new Button(){ FontSize = Styling.Sized (18) }; logoutButton.Text = "Logout"; logoutButton.SetBinding(Button.CommandProperty, new Binding("LogoutCommand")); var versionButton = new Button(){ FontSize = Styling.Sized (10), BackgroundColor = Color.Transparent }; versionButton.SetBinding(Button.TextProperty, new Binding("Version")); // Accomodate iPhone status bar. Padding = new Thickness (Styling.Sized(25), 0, Styling.Sized(25), Styling.Sized(5)); Content = new StackLayout { Children = { aboutLabel, separator, userLabel, new StackLayout { Children = { profileButton, logoutButton }, Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.CenterAndExpand, Spacing = Styling.Sized(20) }, versionButton }, Spacing = Styling.Sized(10), VerticalOptions = LayoutOptions.CenterAndExpand }; }
public UserDetailPage(ViewModelBase viewModel) : base(viewModel) { Title = "Details"; var nameLabel = new SquawkLabel () { FontSize = Styling.Sized (20), FontAttributes = FontAttributes.Bold }; nameLabel.SetBinding (SquawkLabel.TextProperty, new Binding ("Header")); var genderLabel = new SquawkLabel () { FontSize = Styling.Sized (14) }; genderLabel.SetBinding (SquawkLabel.TextProperty, new Binding ("GenderString")); var localeLabel = new SquawkLabel () { FontSize = Styling.Sized (14) }; localeLabel.SetBinding (SquawkLabel.TextProperty, new Binding ("LocaleDetails")); var knownLanguagesLabel = new SquawkLabel () { FontSize = Styling.Sized (14) }; knownLanguagesLabel.SetBinding (Label.TextProperty, new Binding ("KnownLanguagesDisplay")); var practicingLanguagesLabel = new SquawkLabel () { FontSize = Styling.Sized (14) }; practicingLanguagesLabel.SetBinding (SquawkLabel.TextProperty, new Binding ("PracticingLanguagesDisplay")); var userPermissionsLabel = new SquawkLabel () { TextColor = Color.Gray, FontSize = Styling.Sized (12) }; userPermissionsLabel.SetBinding (SquawkLabel.TextProperty, new Binding ("UserPermissionsDisplay")); var spacer = new BoxView () { Color = Color.Transparent, HeightRequest = Styling.Sized (10) }; var descriptionLabel = new SquawkLabel () { FontSize = Styling.Sized (14) }; descriptionLabel.SetBinding (SquawkLabel.TextProperty, new Binding ("Description")); var chatButton = new Button () { Text = "Start Chat", HeightRequest = 40, FontSize = Styling.Sized (14), VerticalOptions = LayoutOptions.Center }; chatButton.SetBinding (Button.CommandProperty, new Binding ("SelectChatCommand")); var scrollableLayout = new StackLayout { Children = { nameLabel, genderLabel, localeLabel, knownLanguagesLabel, practicingLanguagesLabel, userPermissionsLabel, spacer, descriptionLabel }, Padding = 25 }; var scrollView = new ScrollView () { Content = scrollableLayout, Padding = new Thickness (5) }; var buttonLayout = new StackLayout { Children = { chatButton, new BoxView{ HeightRequest = Device.OnPlatform(iOS: 1, Android: 0, WinPhone: 0), Color = Color.Transparent } }, BackgroundColor = Styling.FooterColor, Padding = new Thickness(5, 0) }; buttonLayout.SetBinding (StackLayout.IsVisibleProperty, new Binding ("HasChatOption", BindingMode.OneWay)); Grid grid = new Grid () { VerticalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = GridLength.Auto } }, ColumnDefinitions = { new ColumnDefinition { Width = GridLength.Auto } } }; grid.Children.Add (scrollView, 0, 0); grid.Children.Add (buttonLayout, 0, 1); Content = grid; }