(post.Embedded.Author);
38 | sb.Append($"{authors[0].Name} | {post.Date}
");
39 | sb.Append(content);
40 | sb.Append("");
41 |
42 | return sb.ToString();
43 | }
44 |
45 | public static string FeaturedImage(Post post)
46 | {
47 | if (post.Embedded.WpFeaturedmedia == null)
48 | return string.Empty;
49 |
50 | var images = new List(post.Embedded.WpFeaturedmedia);
51 | var img = images[0];
52 | var imgSrc = img.SourceUrl;
53 |
54 | var sb = new StringBuilder();
55 | sb.Append("
");
64 |
65 | return sb.ToString();
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/Utils/Statics.cs:
--------------------------------------------------------------------------------
1 | namespace WordPressXF.Utils
2 | {
3 | public static class Statics
4 | {
5 | public static string WordpressUrl = "http://www.example.com/wp-json/";
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/ViewModels/BaseViewModel.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Runtime.CompilerServices;
3 |
4 | namespace WordPressXF.ViewModels
5 | {
6 | public class BaseViewModel : INotifyPropertyChanged
7 | {
8 | private bool _isLoading;
9 | public bool IsLoading
10 | {
11 | get => _isLoading;
12 | set { _isLoading = value; OnPropertyChanged(); }
13 | }
14 |
15 | private bool _isRefreshing;
16 | public bool IsRefreshing
17 | {
18 | get => _isRefreshing;
19 | set { _isRefreshing = value; OnPropertyChanged(); }
20 | }
21 |
22 |
23 | public event PropertyChangedEventHandler PropertyChanged;
24 |
25 | protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
26 | {
27 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/ViewModels/NewsViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Diagnostics;
5 | using System.Linq;
6 | using System.Net;
7 | using System.Threading.Tasks;
8 | using System.Windows.Input;
9 | using WordPressPCL.Models;
10 | using WordPressXF.Common;
11 | using WordPressXF.ExtensionMethods;
12 | using WordPressXF.Interfaces;
13 | using WordPressXF.Resources;
14 | using WordPressXF.Services;
15 | using WordPressXF.Utils;
16 | using WordPressXF.Views;
17 | using Xamarin.Forms;
18 |
19 | namespace WordPressXF.ViewModels
20 | {
21 | public class NewsViewModel : BaseViewModel, ISupportIncrementalLoading
22 | {
23 | private readonly WordpressService _wordpressService;
24 |
25 | private int _currentPage = -1;
26 |
27 | private ObservableCollection _posts = new ObservableCollection();
28 | public ObservableCollection Posts
29 | {
30 | get => _posts;
31 | set { _posts = value; OnPropertyChanged(); }
32 | }
33 |
34 | private Post _selectedPost;
35 | public Post SelectedPost
36 | {
37 | get => _selectedPost;
38 | set { _selectedPost = value; OnPropertyChanged(); }
39 | }
40 |
41 | private IEnumerable _comments;
42 | public IEnumerable Comments
43 | {
44 | get => _comments;
45 | set { _comments = value; OnPropertyChanged(); }
46 | }
47 |
48 | private string _commentText;
49 | public string CommentText
50 | {
51 | get => _commentText;
52 | set { _commentText = value; OnPropertyChanged(); PostCommentAsyncCommand.RaiseCanExecuteChange(); }
53 | }
54 |
55 | private bool _isCommenting = false;
56 | public bool IsCommenting
57 | {
58 | get => _isCommenting;
59 | set { _isCommenting = value; OnPropertyChanged(); PostCommentAsyncCommand.RaiseCanExecuteChange(); }
60 | }
61 |
62 | private bool _arePostsNotAvailable = true;
63 | public bool ArePostsNotAvailable
64 | {
65 | get => _arePostsNotAvailable;
66 | set { _arePostsNotAvailable = value; OnPropertyChanged(); }
67 | }
68 |
69 | private AsyncRelayCommand _loadPostsAsyncCommand;
70 | public AsyncRelayCommand LoadPostsAsyncCommand => _loadPostsAsyncCommand ?? (_loadPostsAsyncCommand = new AsyncRelayCommand(LoadPostsAsync));
71 |
72 | private AsyncRelayCommand _postCommentAsyncCommand;
73 | public AsyncRelayCommand PostCommentAsyncCommand => _postCommentAsyncCommand ?? (_postCommentAsyncCommand = new AsyncRelayCommand(PostCommentAsync, CanPostComment));
74 |
75 | private bool CanPostComment()
76 | {
77 | return (!string.IsNullOrEmpty(CommentText) && !IsCommenting);
78 | }
79 |
80 | private async Task LoadPostsAsync()
81 | {
82 | try
83 | {
84 | IsRefreshing = true;
85 |
86 | _currentPage = 0;
87 |
88 | Posts.Clear();
89 |
90 | var posts = (await _wordpressService.GetLatestPostsAsync(_currentPage, PageSize)).ToObservableCollection();
91 | HasMoreItems = posts.Count == PageSize;
92 |
93 | Posts.AddRange(posts);
94 |
95 | ArePostsNotAvailable = !Posts.Any();
96 | }
97 | catch (Exception ex)
98 | {
99 | Debug.WriteLine($"NewsViewModel | LoadPostsAsync | {ex}");
100 | }
101 | finally
102 | {
103 | IsRefreshing = false;
104 | }
105 | }
106 |
107 | private async Task PostCommentAsync()
108 | {
109 | try
110 | {
111 | IsCommenting = true;
112 |
113 | if (await _wordpressService.IsUserAuthenticatedAsync())
114 | {
115 | var comment = await _wordpressService.PostCommentAsync(SelectedPost.Id, CommentText);
116 | if (comment != null)
117 | {
118 | CommentText = null;
119 | await GetCommentsAsync(SelectedPost.Id);
120 | }
121 | }
122 | else
123 | {
124 | await Application.Current.MainPage.DisplayAlert(AppResources.CommentDialogNotAuthorizedTitle, AppResources.CommentDialogNotAuthorizedMessage, AppResources.DialogOk);
125 | }
126 | }
127 | finally
128 | {
129 | IsCommenting = false;
130 | }
131 | }
132 |
133 | private ICommand _selectPostCommand;
134 | public ICommand SelectPostCommand => _selectPostCommand ?? (_selectPostCommand = new Command(SelectPost));
135 |
136 | public NewsViewModel(WordpressService wordpressService)
137 | {
138 | _wordpressService = wordpressService;
139 | }
140 |
141 | private async void SelectPost(Post post)
142 | {
143 | if (post == null)
144 | return;
145 |
146 | Comments = null;
147 | CommentText = null;
148 | SelectedPost = post;
149 |
150 | await GetCommentsAsync(post.Id);
151 | await ((MasterDetailPage)Application.Current.MainPage).Detail.Navigation.PushAsync(GetTabbedPage());
152 | }
153 |
154 | private async Task GetCommentsAsync(int postId)
155 | {
156 | IsLoading = true;
157 |
158 | Comments = await _wordpressService.GetCommentsForPostAsync(postId);
159 |
160 | IsLoading = false;
161 | }
162 |
163 | private TabbedPage GetTabbedPage()
164 | {
165 | return new TabbedPage
166 | {
167 | Title = HtmlTools.Strip(WebUtility.HtmlDecode(SelectedPost.Title.Rendered)),
168 | BindingContext = this,
169 | Children = { new NewsDetailPage(), new CommentPage() }
170 | };
171 | }
172 |
173 | #region ISupportIncrementalLoading members
174 |
175 | public int PageSize { get; set; } = 10;
176 |
177 | private bool _isIncrementalLoading;
178 | public bool IsIncrementalLoading
179 | {
180 | get => _isIncrementalLoading;
181 | set { _isIncrementalLoading = value; OnPropertyChanged(); }
182 | }
183 |
184 | private bool _hasMoreItems = true;
185 | public bool HasMoreItems
186 | {
187 | get => _hasMoreItems;
188 | set { _hasMoreItems = value; OnPropertyChanged(); }
189 | }
190 |
191 | private bool _isLoadingIncrementally;
192 | public bool IsLoadingIncrementally
193 | {
194 | get => _isLoadingIncrementally;
195 | set { _isLoadingIncrementally = value; OnPropertyChanged(); }
196 | }
197 |
198 | private ICommand _loadMoreItemsCommand;
199 | public ICommand LoadMoreItemsCommand => _loadMoreItemsCommand ?? (_loadMoreItemsCommand = new Command(async () => await LoadMoreItemsAsync()));
200 |
201 | private async Task LoadMoreItemsAsync()
202 | {
203 | try
204 | {
205 | IsLoadingIncrementally = true;
206 |
207 | _currentPage++;
208 |
209 | var posts = (await _wordpressService.GetLatestPostsAsync(_currentPage, PageSize)).ToObservableCollection();
210 | HasMoreItems = posts.Count == PageSize;
211 |
212 | Posts.AddRange(posts);
213 | ArePostsNotAvailable = !Posts.Any();
214 | }
215 | catch (Exception ex)
216 | {
217 | Debug.WriteLine($"NewsViewModel | LoadMoreItemsAsync | {ex}");
218 | }
219 | finally
220 | {
221 | IsLoadingIncrementally = false;
222 | }
223 | }
224 |
225 | #endregion
226 | }
227 | }
228 |
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/ViewModels/SettingsViewModel.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using System.Threading.Tasks;
4 | using System.Windows.Input;
5 | using WordPressPCL;
6 | using WordPressPCL.Models;
7 | using WordPressXF.Common;
8 | using WordPressXF.Services;
9 | using Xamarin.Auth;
10 | using Xamarin.Forms;
11 |
12 | namespace WordPressXF.ViewModels
13 | {
14 | public class SettingsViewModel : BaseViewModel
15 | {
16 | private readonly WordpressService _wordPressService;
17 |
18 | private bool _isLoggingIn;
19 | public bool IsLoggingIn
20 | {
21 | get => _isLoggingIn;
22 | set { _isLoggingIn = value; OnPropertyChanged(); LoginCommand.ChangeCanExecute(); }
23 | }
24 |
25 | private bool _isAuthenticated;
26 | public bool IsAuthenticated
27 | {
28 | get => _isAuthenticated;
29 | set { _isAuthenticated = value; OnPropertyChanged(); }
30 | }
31 |
32 | private string _userName;
33 | public string UserName
34 | {
35 | get => _userName;
36 | set { _userName = value; OnPropertyChanged(); }
37 | }
38 |
39 | private string _password;
40 | public string Password
41 | {
42 | get => _password;
43 | set { _password = value; OnPropertyChanged(); }
44 | }
45 |
46 |
47 | private User _currentUser;
48 | public User CurrentUser
49 | {
50 | get => _currentUser;
51 | set { _currentUser = value; OnPropertyChanged(); }
52 | }
53 |
54 | public SettingsViewModel(WordpressService wordPressService)
55 | {
56 | _wordPressService = wordPressService;
57 | }
58 |
59 | private AsyncRelayCommand _tryAutoLoginCommand;
60 | public AsyncRelayCommand TryAutoLoginCommand => _tryAutoLoginCommand ?? (_tryAutoLoginCommand = new AsyncRelayCommand(TryAutoLogin));
61 |
62 | private Command _loginCommand;
63 | public Command LoginCommand => _loginCommand ?? (_loginCommand = new Command(Login, CanLogin));
64 |
65 | private bool CanLogin()
66 | {
67 | return !IsLoggingIn;
68 | }
69 |
70 | private ICommand _logoutCommand;
71 | public ICommand LogoutCommand => _logoutCommand ?? (_logoutCommand = new Command(Logout));
72 |
73 |
74 | public async Task TryAutoLogin()
75 | {
76 | var data = (await AccountStore.Create().FindAccountsForServiceAsync("wordpress")).FirstOrDefault();
77 |
78 | if (data == null)
79 | return;
80 |
81 | var userName = data.Username;
82 | var password = data.Properties["password"];
83 |
84 | var user = await _wordPressService.LoginAsync(userName, password);
85 | if (user != null)
86 | CurrentUser = user;
87 | }
88 |
89 | public async void Login()
90 | {
91 |
92 | IsLoggingIn = true;
93 |
94 | if (!string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(Password))
95 | {
96 | var user = await _wordPressService.LoginAsync(UserName, Password);
97 | if (user != null)
98 | {
99 | // Store username & JWT token for logging in on next app launch
100 | await AccountStore.Create().SaveAsync(new Account(UserName, new Dictionary { { "password", Password } }), "wordpress");
101 | CurrentUser = user;
102 | }
103 | }
104 |
105 | IsLoggingIn = false;
106 | }
107 |
108 |
109 | public async void Logout()
110 | {
111 | _wordPressService.Logout();
112 | CurrentUser = null;
113 |
114 | var data = (await AccountStore.Create().FindAccountsForServiceAsync("wordpress")).FirstOrDefault();
115 |
116 | if (data == null)
117 | return;
118 |
119 | await AccountStore.Create().DeleteAsync(data, "wordpress");
120 | }
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/Views/AppShell/AppShellMaster.xaml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 | WordPressXF.Assets.menuheader.png
13 |
14 |
15 |
16 |
18 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
33 |
34 |
36 |
37 |
38 |
40 |
42 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
54 |
56 |
58 |
59 |
60 |
61 |
69 |
70 |
71 |
78 |
79 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/Views/AppShell/AppShellMaster.xaml.cs:
--------------------------------------------------------------------------------
1 | using Xamarin.Forms;
2 | using Xamarin.Forms.Xaml;
3 |
4 | namespace WordPressXF.Views.AppShell
5 | {
6 | [XamlCompilation(XamlCompilationOptions.Compile)]
7 | public partial class AppShellMaster : ContentPage
8 | {
9 | public ListView PrimaryListView { get; set; }
10 | public ListView SecondaryListView { get; set; }
11 |
12 | public AppShellMaster()
13 | {
14 | InitializeComponent();
15 |
16 | if (Device.RuntimePlatform == Device.iOS)
17 | Icon = "hamburger.png";
18 |
19 | BindingContext = new AppShellMasterViewModel();
20 |
21 | PrimaryListView = Primary;
22 | SecondaryListView = Secondary;
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/Views/AppShell/AppShellMasterViewModel.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.ObjectModel;
2 |
3 | namespace WordPressXF.Views.AppShell
4 | {
5 | public class AppShellMasterViewModel
6 | {
7 | public ObservableCollection PrimaryMenuItems { get; set; }
8 | public ObservableCollection SecondaryMenuItems { get; set; }
9 |
10 | public AppShellMasterViewModel()
11 | {
12 | PrimaryMenuItems = new ObservableCollection(new[]
13 | {
14 | new AppShellMenuItem { Id = 0, Title = "News", TargetType = typeof(NewsOverviewPage) },
15 | });
16 |
17 | SecondaryMenuItems = new ObservableCollection(new[]
18 | {
19 | new AppShellMenuItem { Id = 0, Title = "Settings", TargetType = typeof(SettingsPage) },
20 | });
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/Views/AppShell/AppShellMenuItem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WordPressXF.Views.AppShell
4 | {
5 | public class AppShellMenuItem
6 | {
7 | public int Id { get; set; }
8 | public string Title { get; set; }
9 | public Type TargetType { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/Views/AppShell/AppShellPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/Views/AppShell/AppShellPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | using Xamarin.Forms;
8 | using Xamarin.Forms.Xaml;
9 |
10 | namespace WordPressXF.Views.AppShell
11 | {
12 | [XamlCompilation(XamlCompilationOptions.Compile)]
13 | public partial class AppShellPage : MasterDetailPage
14 | {
15 | public AppShellPage()
16 | {
17 | InitializeComponent();
18 |
19 | MasterPage.PrimaryListView.ItemSelected += ListViewOnItemSelected;
20 | MasterPage.SecondaryListView.ItemSelected += ListViewOnItemSelected;
21 | }
22 |
23 | private void ListViewOnItemSelected(object sender, SelectedItemChangedEventArgs e)
24 | {
25 | if (!(e.SelectedItem is AppShellMenuItem item))
26 | return;
27 |
28 | ((ListView)sender).SelectedItem = null;
29 |
30 | if (item.TargetType == null)
31 | return;
32 |
33 | var page = (Page)Activator.CreateInstance(item.TargetType);
34 | var navigationPage = new NavigationPage(page);
35 | NavigationPage.SetHasNavigationBar(navigationPage, false);
36 |
37 | Detail.Navigation.PushAsync(navigationPage);
38 | IsPresented = false;
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/Views/CommentPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
28 |
29 |
30 |
31 |
33 |
34 |
35 |
36 |
37 |
38 |
40 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
59 |
60 |
61 |
62 |
65 |
66 |
67 |
68 |
69 |
70 |
73 |
74 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/Views/CommentPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using Xamarin.Forms;
2 | using Xamarin.Forms.Xaml;
3 |
4 | namespace WordPressXF.Views
5 | {
6 | [XamlCompilation(XamlCompilationOptions.Compile)]
7 | public partial class CommentPage : ContentPage
8 | {
9 | public CommentPage ()
10 | {
11 | InitializeComponent ();
12 |
13 | if (Device.RuntimePlatform == Device.iOS)
14 | Icon = new FileImageSource { File = "comments.png" };
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/Views/NewsDetailPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
19 |
20 |
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/Views/NewsDetailPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using Xamarin.Forms;
2 | using Xamarin.Forms.Xaml;
3 |
4 | namespace WordPressXF.Views
5 | {
6 | [XamlCompilation(XamlCompilationOptions.Compile)]
7 | public partial class NewsDetailPage : ContentPage
8 | {
9 | public NewsDetailPage()
10 | {
11 | InitializeComponent();
12 |
13 | if (Device.RuntimePlatform == Device.iOS)
14 | Icon = new FileImageSource { File = "post.png" };
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/Views/NewsOverviewPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | WordPressXF.Assets.placeholder.jpg
20 |
21 |
22 |
23 |
24 |
25 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
51 |
52 |
53 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/Views/NewsOverviewPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using CommonServiceLocator;
2 | using WordPressXF.ViewModels;
3 | using Xamarin.Forms;
4 | using Xamarin.Forms.Xaml;
5 |
6 | namespace WordPressXF.Views
7 | {
8 | [XamlCompilation(XamlCompilationOptions.Compile)]
9 | public partial class NewsOverviewPage : ContentPage
10 | {
11 | public NewsOverviewPage()
12 | {
13 | InitializeComponent();
14 |
15 | BindingContext = ServiceLocator.Current.GetInstance();
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/Views/Settings/LoginPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
20 |
22 |
25 |
27 |
28 |
30 |
32 |
33 |
34 |
35 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/Views/Settings/LoginPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using Xamarin.Forms;
2 | using Xamarin.Forms.Xaml;
3 |
4 | namespace WordPressXF.Views.Settings
5 | {
6 | [XamlCompilation(XamlCompilationOptions.Compile)]
7 | public partial class LoginPage : ContentPage
8 | {
9 | public LoginPage()
10 | {
11 | InitializeComponent();
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/Views/SettingsPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/Views/SettingsPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using CommonServiceLocator;
2 | using WordPressXF.ViewModels;
3 | using Xamarin.Forms;
4 | using Xamarin.Forms.Xaml;
5 |
6 | namespace WordPressXF.Views
7 | {
8 | [XamlCompilation(XamlCompilationOptions.Compile)]
9 | public partial class SettingsPage : TabbedPage
10 | {
11 | public SettingsPage()
12 | {
13 | InitializeComponent();
14 |
15 | BindingContext = ServiceLocator.Current.GetInstance();
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/Views/SplashScreen.xaml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
11 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/Views/SplashScreen.xaml.cs:
--------------------------------------------------------------------------------
1 | using CommonServiceLocator;
2 | using WordPressXF.ViewModels;
3 | using WordPressXF.Views.AppShell;
4 | using Xamarin.Forms;
5 | using Xamarin.Forms.Xaml;
6 |
7 | namespace WordPressXF.Views
8 | {
9 | [XamlCompilation(XamlCompilationOptions.Compile)]
10 | public partial class SplashScreen : ContentPage
11 | {
12 | private readonly NewsViewModel _viewModel;
13 |
14 | public SplashScreen()
15 | {
16 | InitializeComponent();
17 |
18 | _viewModel = ServiceLocator.Current.GetInstance();
19 | BindingContext = _viewModel;
20 | }
21 |
22 | protected override async void OnAppearing()
23 | {
24 | base.OnAppearing();
25 |
26 | // try to autologin
27 | await ServiceLocator.Current.GetInstance().TryAutoLoginCommand.ExecuteAsync();
28 |
29 | await _viewModel.LoadPostsAsyncCommand.ExecuteAsync();
30 | Application.Current.MainPage = new AppShellPage();
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/WordPressXF/WordPressXF/WordPressXF/WordPressXF.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | App.xaml
29 |
30 |
31 | True
32 | True
33 | AppResources.resx
34 |
35 |
36 |
37 |
38 |
39 | ResXFileCodeGenerator
40 | AppResources.Designer.cs
41 |
42 |
43 | MSBuild:UpdateDesignTimeXaml
44 |
45 |
46 | MSBuild:UpdateDesignTimeXaml
47 |
48 |
49 | MSBuild:UpdateDesignTimeXaml
50 |
51 |
52 | MSBuild:UpdateDesignTimeXaml
53 |
54 |
55 | MSBuild:UpdateDesignTimeXaml
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------