public ServerListPage() { listView = new ListView { ItemTemplate = new DataTemplate(typeof(ServerCell)), SeparatorColor = Color.FromHex("#ddd"), BackgroundColor = Color.Black, IsPullToRefreshEnabled = true, HasUnevenRows = true, StyleId = "serverListView" }; listView.SetBinding <ServerListViewModel>(ListView.RefreshCommandProperty, x => x.GetServersCommand); listView.ItemTapped += OnItemSelected; listView.Refreshing += OnListViewRefreshing; StyleId = "serverListPage"; Title = "Servers"; Content = new StackLayout { VerticalOptions = LayoutOptions.Fill, Children = { listView } }; ToolbarItems.Add(new ToolbarItem("add", PlatformImage.Resolver("plus.png"), async() => await Navigation.PushAsync(new ServerPage()))); }
public PlayerListPage() { listView = new InfiniteListView { HasUnevenRows = true, ItemTemplate = new DataTemplate(typeof(PlayerCell)), SeparatorColor = Color.FromHex("#ddd"), IsPullToRefreshEnabled = true, Header = new Image { Source = PlatformImage.Resolver("header.jpg") }, BackgroundColor = Color.Black, LoadMoreCommand = ViewModel.LoadMoreCommand, ItemsSource = ViewModel.Players, StyleId = "playerListView" }; listView.ItemTapped += OnItemSelected; listView.Refreshing += OnListViewRefreshing; StyleId = "playerListPage"; var layout = new StackLayout { VerticalOptions = LayoutOptions.Fill, Children = { listView } }; if (SevenDays.Core.Helpers.Settings.ShowAds) { layout.Children.Add(new AdMobBuddyControl { AdUnitId = App.AdMobId, StyleId = "admobControl" }); } Content = layout; }
public MenuPage() { Icon = PlatformImage.Resolver("menu.png"); Title = "menu"; // The Title property must be set. BackgroundColor = Color.FromHex("333333"); StyleId = "menuPage"; var cell = new DataTemplate(typeof(MenuCell)); cell.SetBinding(MenuCell.TextProperty, "Title"); cell.SetBinding(MenuCell.ImageSourceProperty, "IconSource"); var menuItems = new List <Model.MenuItem> { new Model.MenuItem { Title = "Players", IconSource = PlatformImage.Resolver("people.png"), TargetType = typeof(PlayerListPage) }, new Model.MenuItem { Title = "Servers", IconSource = PlatformImage.Resolver("servers.png"), TargetType = typeof(ServerListPage) }, new Model.MenuItem { Title = "Map", IconSource = PlatformImage.Resolver("map.png"), TargetType = typeof(MapPage) }, new Model.MenuItem { Title = "About", IconSource = PlatformImage.Resolver("info.png"), TargetType = typeof(AboutPage) } }; Menu = new ListView { ItemsSource = menuItems, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent, SeparatorVisibility = SeparatorVisibility.None, ItemTemplate = cell, HasUnevenRows = true, StyleId = "menuListView" }; var menuLabel = new ContentView { Padding = new Thickness(10, 36, 0, 5), Content = new Label { TextColor = Color.FromHex("AAAAAA"), Text = "MENU", }, StyleId = "menuLabel" }; var layout = new StackLayout { Spacing = 0, VerticalOptions = LayoutOptions.FillAndExpand, Children = { menuLabel, Menu } }; Content = layout; }
public PlayerCell() { var profileImage = new CircleImage { BorderColor = Color.Teal, BorderThickness = 2, HeightRequest = 50, WidthRequest = 50, Aspect = Aspect.AspectFill, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, StyleId = "profileImage" }; profileImage.SetBinding <PlayerViewModel>(Image.SourceProperty, x => x.Avatar); var nameLabel = new Label() { FontFamily = "HelveticaNeue-Medium", FontSize = Device.OnPlatform(18, 18, 24), TextColor = Color.White, StyleId = "nameLabel" }; nameLabel.SetBinding <PlayerViewModel>(Label.TextProperty, x => x.Name); var steamLabel = new Label() { FontAttributes = FontAttributes.Bold, FontSize = 12, StyleId = "steamLabel" }; steamLabel.SetBinding <PlayerViewModel>(Label.TextColorProperty, x => x.SteamColor); steamLabel.SetBinding <PlayerViewModel>(Label.TextProperty, x => x.SteamAvailability); var onlineImage = new Image() { Source = PlatformImage.Resolver("online.png"), HeightRequest = 8, WidthRequest = 8, StyleId = "onlineImage" }; onlineImage.SetBinding <PlayerViewModel>(Image.IsVisibleProperty, x => x.ShouldShowAsOnline); var onLineLabel = new Label() { Text = "Online", TextColor = Color.Green, FontSize = 12, IsVisible = false, StyleId = "onlineLabel" }; onLineLabel.SetBinding <PlayerViewModel>(Label.IsVisibleProperty, x => x.ShouldShowAsOnline); // Offline image and label var offlineImage = new Image() { Source = PlatformImage.Resolver("offline.png"), HeightRequest = 8, WidthRequest = 8, StyleId = "offlineImage" }; offlineImage.SetBinding <PlayerViewModel>(Image.IsVisibleProperty, x => x.ShouldShowAsOffline); var offLineLabel = new Label() { Text = "Offline", TextColor = Color.FromHex("#ddd"), FontSize = 12, IsVisible = false, StyleId = "offlineLabel" }; offLineLabel.SetBinding <PlayerViewModel>(Label.IsVisibleProperty, x => x.ShouldShowAsOffline); var statusLayout = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { onlineImage, onLineLabel, offlineImage, offLineLabel, steamLabel } }; var timeLabel = new Label { TextColor = Color.FromHex("#ddd"), FontAttributes = FontAttributes.Italic, FontSize = 10, StyleId = "timeLabel" }; timeLabel.SetBinding <PlayerViewModel>(Label.TextProperty, x => x.LastLogOff); var detailsLayout = new StackLayout { Padding = new Thickness(10, 0, 0, 0), Spacing = 0, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { nameLabel, statusLayout, timeLabel } }; var tapImage = new Image() { Source = PlatformImage.Resolver("tap.png"), HorizontalOptions = LayoutOptions.End, HeightRequest = 12, StyleId = "tapImage" }; var cellLayout = new StackLayout { Spacing = 0, Padding = new Thickness(10, 5, 10, 5), Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { profileImage, detailsLayout, tapImage } }; StyleId = "playerCell"; this.View = cellLayout; }
public ServerCell() { var favoriteAction = new MenuItem { Text = "Favorite" }; favoriteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding(".")); favoriteAction.SetBinding <ServerViewModel>(MenuItem.CommandProperty, x => x.SetDefaultCommand); favoriteAction.Clicked += (sender, e) => { var mi = (MenuItem)sender; var vm = (ServerViewModel)mi.CommandParameter; MessagingCenter.Send <ServerCell, ServerViewModel>(this, "Favorite", vm); }; var deleteAction = new MenuItem { Text = "Delete", IsDestructive = true }; deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding(".")); deleteAction.SetBinding <ServerViewModel>(MenuItem.CommandProperty, x => x.DeleteCommand); deleteAction.Clicked += (sender, e) => { var mi = (MenuItem)sender; var vm = (ServerViewModel)mi.CommandParameter; MessagingCenter.Send <ServerCell, ServerViewModel>(this, "Delete", vm); }; ContextActions.Add(favoriteAction); ContextActions.Add(deleteAction); var image = new Image { Source = PlatformImage.Resolver("favorite.png"), HeightRequest = 40, WidthRequest = 40, Aspect = Aspect.AspectFill, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, }; image.SetBinding <ServerViewModel>(Image.IsVisibleProperty, x => x.IsFavorite); var notimage = new Image { HeightRequest = 40, WidthRequest = 40, Aspect = Aspect.AspectFill, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, }; notimage.SetBinding <ServerViewModel>(Image.IsVisibleProperty, x => x.IsNotFavorite); var nameLabel = new Label() { FontFamily = "HelveticaNeue-Medium", FontSize = Device.OnPlatform(18, 18, 24), TextColor = Color.White, StyleId = "nameLabel" }; nameLabel.SetBinding <ServerViewModel>(Label.TextProperty, x => x.Host); var detailsLayout = new StackLayout { Padding = new Thickness(10, 0, 0, 0), Spacing = 0, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center, Children = { nameLabel } }; var cellLayout = new StackLayout { Spacing = 0, Padding = new Thickness(10, 10, 10, 5), Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { image, notimage, detailsLayout } }; StyleId = "serverCell"; this.View = cellLayout; }