diff --git a/src/App/App.csproj b/src/App/App.csproj index 6ca26a8cf..0ec75a9d2 100644 --- a/src/App/App.csproj +++ b/src/App/App.csproj @@ -22,6 +22,9 @@ + + EnvironmentPage.xaml + HintPage.xaml diff --git a/src/App/Pages/Accounts/EnvironmentPage.xaml b/src/App/Pages/Accounts/EnvironmentPage.xaml new file mode 100644 index 000000000..164139722 --- /dev/null +++ b/src/App/Pages/Accounts/EnvironmentPage.xaml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/App/Pages/Accounts/EnvironmentPage.xaml.cs b/src/App/Pages/Accounts/EnvironmentPage.xaml.cs new file mode 100644 index 000000000..3b70d65c3 --- /dev/null +++ b/src/App/Pages/Accounts/EnvironmentPage.xaml.cs @@ -0,0 +1,21 @@ +using System; + +namespace Bit.App.Pages +{ + public partial class EnvironmentPage : BaseContentPage + { + private EnvironmentPageViewModel _vm; + + public EnvironmentPage() + { + InitializeComponent(); + _vm = BindingContext as EnvironmentPageViewModel; + _vm.Page = this; + } + + private async void Submit_Clicked(object sender, EventArgs e) + { + await _vm.SubmitAsync(); + } + } +} diff --git a/src/App/Pages/Accounts/EnvironmentPageViewModel.cs b/src/App/Pages/Accounts/EnvironmentPageViewModel.cs new file mode 100644 index 000000000..611911d79 --- /dev/null +++ b/src/App/Pages/Accounts/EnvironmentPageViewModel.cs @@ -0,0 +1,58 @@ +using Bit.App.Resources; +using Bit.Core.Abstractions; +using Bit.Core.Utilities; +using System.Threading.Tasks; + +namespace Bit.App.Pages +{ + public class EnvironmentPageViewModel : BaseViewModel + { + private readonly IPlatformUtilsService _platformUtilsService; + private readonly IEnvironmentService _environmentService; + + public EnvironmentPageViewModel() + { + _platformUtilsService = ServiceContainer.Resolve("platformUtilsService"); + _environmentService = ServiceContainer.Resolve("environmentService"); + + PageTitle = AppResources.Settings; + BaseUrl = _environmentService.BaseUrl; + WebVaultUrl = _environmentService.WebVaultUrl; + ApiUrl = _environmentService.ApiUrl; + IdentityUrl = _environmentService.IdentityUrl; + IconsUrl = _environmentService.IconsUrl; + NotificationsUrls = _environmentService.NotificationsUrl; + } + + public string BaseUrl { get; set; } + public string ApiUrl { get; set; } + public string IdentityUrl { get; set; } + public string WebVaultUrl { get; set; } + public string IconsUrl { get; set; } + public string NotificationsUrls { get; set; } + + public async Task SubmitAsync() + { + var resUrls = await _environmentService.SetUrlsAsync(new Core.Models.Data.EnvironmentUrlData + { + Base = BaseUrl, + Api = ApiUrl, + Identity = IdentityUrl, + WebVault = WebVaultUrl, + Icons = IconsUrl, + Notifications = NotificationsUrls + }); + + // re-set urls since service can change them, ex: prefixing https:// + BaseUrl = resUrls.Base; + WebVaultUrl = resUrls.WebVault; + ApiUrl = resUrls.Api; + IdentityUrl = resUrls.Identity; + IconsUrl = resUrls.Icons; + NotificationsUrls = resUrls.Notifications; + + _platformUtilsService.ShowToast("success", null, AppResources.EnvironmentSaved); + await Page.Navigation.PopModalAsync(); + } + } +} diff --git a/src/App/Pages/HomePage.xaml b/src/App/Pages/HomePage.xaml index 8b569aa4d..d992d854b 100644 --- a/src/App/Pages/HomePage.xaml +++ b/src/App/Pages/HomePage.xaml @@ -4,23 +4,24 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Bit.App.Pages.HomePage" xmlns:pages="clr-namespace:Bit.App.Pages" + xmlns:controls="clr-namespace:Bit.App.Controls" xmlns:u="clr-namespace:Bit.App.Utilities" - xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core" x:DataType="pages:HomeViewModel" Title="{Binding PageTitle}"> - - - + + + diff --git a/src/App/Pages/HomePage.xaml.cs b/src/App/Pages/HomePage.xaml.cs index 3951ade5e..ad50b53b9 100644 --- a/src/App/Pages/HomePage.xaml.cs +++ b/src/App/Pages/HomePage.xaml.cs @@ -1,10 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Xamarin.Forms; -using Xamarin.Forms.Xaml; namespace Bit.App.Pages { @@ -24,5 +19,10 @@ namespace Bit.App.Pages { Navigation.PushModalAsync(new NavigationPage(new RegisterPage())); } + + private void Settings_Clicked(object sender, EventArgs e) + { + Navigation.PushModalAsync(new NavigationPage(new EnvironmentPage())); + } } } diff --git a/src/App/Styles/Android.xaml b/src/App/Styles/Android.xaml index 757988851..b7aa9a338 100644 --- a/src/App/Styles/Android.xaml +++ b/src/App/Styles/Android.xaml @@ -7,7 +7,18 @@ - + + + + + - + + + + + +