mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-23 11:45:38 +01:00
environment page
This commit is contained in:
parent
9965121011
commit
faf690d899
@ -22,6 +22,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Update="Pages\Accounts\EnvironmentPage.xaml.cs">
|
||||||
|
<DependentUpon>EnvironmentPage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Update="Pages\Accounts\HintPage.xaml.cs">
|
<Compile Update="Pages\Accounts\HintPage.xaml.cs">
|
||||||
<DependentUpon>HintPage.xaml</DependentUpon>
|
<DependentUpon>HintPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
88
src/App/Pages/Accounts/EnvironmentPage.xaml
Normal file
88
src/App/Pages/Accounts/EnvironmentPage.xaml
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<pages:BaseContentPage
|
||||||
|
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
x:Class="Bit.App.Pages.EnvironmentPage"
|
||||||
|
xmlns:pages="clr-namespace:Bit.App.Pages"
|
||||||
|
xmlns:u="clr-namespace:Bit.App.Utilities"
|
||||||
|
x:DataType="pages:EnvironmentPageViewModel"
|
||||||
|
Title="{Binding PageTitle}">
|
||||||
|
|
||||||
|
<ContentPage.BindingContext>
|
||||||
|
<pages:EnvironmentPageViewModel />
|
||||||
|
</ContentPage.BindingContext>
|
||||||
|
|
||||||
|
<ContentPage.ToolbarItems>
|
||||||
|
<ToolbarItem Text="{u:I18n Save}" Clicked="Submit_Clicked" />
|
||||||
|
</ContentPage.ToolbarItems>
|
||||||
|
|
||||||
|
<ScrollView>
|
||||||
|
<StackLayout Spacing="20">
|
||||||
|
<StackLayout StyleClass="box">
|
||||||
|
<StackLayout StyleClass="box-row-header">
|
||||||
|
<Label Text="{u:I18n SelfHostedEnvironment}"
|
||||||
|
StyleClass="box-header, box-header-platform" />
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout StyleClass="box-row">
|
||||||
|
<Label
|
||||||
|
Text="{u:I18n ServerUrl}"
|
||||||
|
StyleClass="box-label" />
|
||||||
|
<Entry
|
||||||
|
Text="{Binding BaseUrl}"
|
||||||
|
Keyboard="Url"
|
||||||
|
Placeholder="ex. https://bitwarden.company.com"
|
||||||
|
StyleClass="box-value" />
|
||||||
|
</StackLayout>
|
||||||
|
<Label
|
||||||
|
Text="{u:I18n SelfHostedEnvironmentFooter}"
|
||||||
|
StyleClass="box-footer-label" />
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout StyleClass="box">
|
||||||
|
<StackLayout StyleClass="box-row-header">
|
||||||
|
<Label Text="{u:I18n CustomEnvironment}"
|
||||||
|
StyleClass="box-header, box-header-platform" />
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout StyleClass="box-row">
|
||||||
|
<Label
|
||||||
|
Text="{u:I18n WebVaultUrl}"
|
||||||
|
StyleClass="box-label" />
|
||||||
|
<Entry
|
||||||
|
Text="{Binding WebVaultUrl}"
|
||||||
|
Keyboard="Url"
|
||||||
|
StyleClass="box-value" />
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout StyleClass="box-row">
|
||||||
|
<Label
|
||||||
|
Text="{u:I18n ApiUrl}"
|
||||||
|
StyleClass="box-label" />
|
||||||
|
<Entry
|
||||||
|
Text="{Binding ApiUrl}"
|
||||||
|
Keyboard="Url"
|
||||||
|
StyleClass="box-value" />
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout StyleClass="box-row">
|
||||||
|
<Label
|
||||||
|
Text="{u:I18n IdentityUrl}"
|
||||||
|
StyleClass="box-label" />
|
||||||
|
<Entry
|
||||||
|
Text="{Binding IdentityUrl}"
|
||||||
|
Keyboard="Url"
|
||||||
|
StyleClass="box-value" />
|
||||||
|
</StackLayout>
|
||||||
|
<StackLayout StyleClass="box-row">
|
||||||
|
<Label
|
||||||
|
Text="{u:I18n IconsUrl}"
|
||||||
|
StyleClass="box-label" />
|
||||||
|
<Entry
|
||||||
|
Text="{Binding IconsUrl}"
|
||||||
|
Keyboard="Url"
|
||||||
|
StyleClass="box-value" />
|
||||||
|
</StackLayout>
|
||||||
|
<Label
|
||||||
|
Text="{u:I18n CustomEnvironmentFooter}"
|
||||||
|
StyleClass="box-footer-label" />
|
||||||
|
</StackLayout>
|
||||||
|
</StackLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
</pages:BaseContentPage>
|
21
src/App/Pages/Accounts/EnvironmentPage.xaml.cs
Normal file
21
src/App/Pages/Accounts/EnvironmentPage.xaml.cs
Normal file
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
58
src/App/Pages/Accounts/EnvironmentPageViewModel.cs
Normal file
58
src/App/Pages/Accounts/EnvironmentPageViewModel.cs
Normal file
@ -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<IPlatformUtilsService>("platformUtilsService");
|
||||||
|
_environmentService = ServiceContainer.Resolve<IEnvironmentService>("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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,23 +4,24 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="Bit.App.Pages.HomePage"
|
x:Class="Bit.App.Pages.HomePage"
|
||||||
xmlns:pages="clr-namespace:Bit.App.Pages"
|
xmlns:pages="clr-namespace:Bit.App.Pages"
|
||||||
|
xmlns:controls="clr-namespace:Bit.App.Controls"
|
||||||
xmlns:u="clr-namespace:Bit.App.Utilities"
|
xmlns:u="clr-namespace:Bit.App.Utilities"
|
||||||
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
|
|
||||||
x:DataType="pages:HomeViewModel"
|
x:DataType="pages:HomeViewModel"
|
||||||
Title="{Binding PageTitle}">
|
Title="{Binding PageTitle}">
|
||||||
<ContentPage.BindingContext>
|
<ContentPage.BindingContext>
|
||||||
<pages:HomeViewModel />
|
<pages:HomeViewModel />
|
||||||
</ContentPage.BindingContext>
|
</ContentPage.BindingContext>
|
||||||
|
|
||||||
<StackLayout>
|
<StackLayout Spacing="0" Padding="10, 5">
|
||||||
<Button Text=""
|
<controls:FaButton Text=""
|
||||||
class="fa"
|
StyleClass="btn-muted, btn-icon, btn-icon-platform"
|
||||||
HorizontalOptions="Start"></Button>
|
HorizontalOptions="Start"
|
||||||
<StackLayout VerticalOptions="CenterAndExpand">
|
Clicked="Settings_Clicked" />
|
||||||
|
<StackLayout VerticalOptions="CenterAndExpand" Spacing="15">
|
||||||
<Image Source="logo.png"
|
<Image Source="logo.png"
|
||||||
VerticalOptions="Center" />
|
VerticalOptions="Center" />
|
||||||
<Label Text="{u:I18n LoginOrCreateNewAccount}"
|
<Label Text="{u:I18n LoginOrCreateNewAccount}"
|
||||||
class="text-lg"
|
StyleClass="text-lg"
|
||||||
HorizontalTextAlignment="Center"></Label>
|
HorizontalTextAlignment="Center"></Label>
|
||||||
<Button Text="{u:I18n LogIn}"
|
<Button Text="{u:I18n LogIn}"
|
||||||
Clicked="LogIn_Clicked"></Button>
|
Clicked="LogIn_Clicked"></Button>
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using Xamarin.Forms.Xaml;
|
|
||||||
|
|
||||||
namespace Bit.App.Pages
|
namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
@ -24,5 +19,10 @@ namespace Bit.App.Pages
|
|||||||
{
|
{
|
||||||
Navigation.PushModalAsync(new NavigationPage(new RegisterPage()));
|
Navigation.PushModalAsync(new NavigationPage(new RegisterPage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Settings_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Navigation.PushModalAsync(new NavigationPage(new EnvironmentPage()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,18 @@
|
|||||||
<Setter Property="Margin"
|
<Setter Property="Margin"
|
||||||
Value="-4, 0" />
|
Value="-4, 0" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<!-- Buttons -->
|
||||||
|
|
||||||
|
<Style TargetType="Button"
|
||||||
|
ApplyToDerivedTypes="True"
|
||||||
|
Class="btn-icon-platform">
|
||||||
|
<Setter Property="WidthRequest"
|
||||||
|
Value="37" />
|
||||||
|
<Setter Property="FontSize"
|
||||||
|
Value="25" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
<!-- List -->
|
<!-- List -->
|
||||||
|
|
||||||
<Style TargetType="ListView"
|
<Style TargetType="ListView"
|
||||||
|
@ -12,41 +12,56 @@
|
|||||||
Value="{StaticResource TextColor}" />
|
Value="{StaticResource TextColor}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style TargetType="Label"
|
<Style TargetType="Label"
|
||||||
x:Key="text-default">
|
Class="text-default">
|
||||||
<Setter Property="TextColor"
|
<Setter Property="TextColor"
|
||||||
Value="{StaticResource TextColor}" />
|
Value="{StaticResource TextColor}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style TargetType="Label"
|
<Style TargetType="Label"
|
||||||
x:Key="text-muted">
|
Class="text-muted">
|
||||||
<Setter Property="TextColor"
|
<Setter Property="TextColor"
|
||||||
Value="{StaticResource MutedColor}" />
|
Value="{StaticResource MutedColor}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style TargetType="Label"
|
<Style TargetType="Label"
|
||||||
x:Key="text-danger">
|
Class="text-danger">
|
||||||
<Setter Property="TextColor"
|
<Setter Property="TextColor"
|
||||||
Value="{StaticResource DangerColor}" />
|
Value="{StaticResource DangerColor}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style TargetType="Label"
|
<Style TargetType="Label"
|
||||||
x:Key="text-success">
|
Class="text-success">
|
||||||
<Setter Property="TextColor"
|
<Setter Property="TextColor"
|
||||||
Value="{StaticResource SuccessColor}" />
|
Value="{StaticResource SuccessColor}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style TargetType="Label"
|
<Style TargetType="Label"
|
||||||
x:Key="text-sm">
|
Class="text-sm">
|
||||||
<Setter Property="FontSize"
|
<Setter Property="FontSize"
|
||||||
Value="Small" />
|
Value="Small" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style TargetType="Label"
|
<Style TargetType="Label"
|
||||||
x:Key="text-lg">
|
Class="text-lg">
|
||||||
<Setter Property="FontSize"
|
<Setter Property="FontSize"
|
||||||
Value="Large" />
|
Value="Large" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style TargetType="Label"
|
<Style TargetType="Label"
|
||||||
x:Key="text-bold">
|
Class="text-bold">
|
||||||
<Setter Property="FontAttributes"
|
<Setter Property="FontAttributes"
|
||||||
Value="Bold" />
|
Value="Bold" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<!-- Buttons -->
|
||||||
|
<Style TargetType="Button"
|
||||||
|
ApplyToDerivedTypes="True"
|
||||||
|
Class="btn-icon">
|
||||||
|
<Setter Property="BackgroundColor"
|
||||||
|
Value="Transparent" />
|
||||||
|
</Style>
|
||||||
|
<Style TargetType="Button"
|
||||||
|
Class="btn-muted"
|
||||||
|
ApplyToDerivedTypes="True">
|
||||||
|
<Setter Property="TextColor"
|
||||||
|
Value="{StaticResource MutedColor}" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
|
||||||
<!-- List -->
|
<!-- List -->
|
||||||
<Style TargetType="ListView"
|
<Style TargetType="ListView"
|
||||||
Class="list">
|
Class="list">
|
||||||
|
Loading…
Reference in New Issue
Block a user