-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Frontend.XF: added the side menu & settings page
Added the settings page. Added the settings icon and side menu.
- Loading branch information
Showing
7 changed files
with
284 additions
and
7 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<ContentPage | ||
xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="GWallet.Frontend.XF.SettingsPage"> | ||
|
||
<AbsoluteLayout> | ||
<StackLayout x:Name="mainLayout" | ||
AbsoluteLayout.LayoutFlags="XProportional,SizeProportional" | ||
AbsoluteLayout.LayoutBounds="0.5,50,0.7,1" | ||
VerticalOptions="FillAndExpand"> | ||
|
||
<Label x:Name="titleLabel" Text="" Margin="0,0,0,10" HorizontalTextAlignment="Center" TextTransform="Uppercase"/> | ||
|
||
<!-- Check you still remember your payment password--> | ||
<StackLayout Spacing="10" | ||
IsVisible="false"> | ||
<Entry x:Name="passwordEntry" | ||
IsPassword="true" | ||
Focused="ClearResult" | ||
Text="" | ||
Placeholder="Type your password"/> | ||
|
||
<Button Text="Check my password" | ||
Clicked="OnCheckPasswordButtonClicked" | ||
HorizontalOptions="FillAndExpand"> | ||
<Button.Triggers> | ||
<DataTrigger TargetType="Button" | ||
Binding="{Binding Text.Length, Source={x:Reference passwordEntry}}" | ||
Value="0"> | ||
<Setter Property="IsEnabled" Value="False"/> | ||
</DataTrigger> | ||
</Button.Triggers> | ||
</Button> | ||
<StackLayout.Triggers> | ||
<DataTrigger TargetType="StackLayout" | ||
Binding="{Binding Text, Source={x:Reference titleLabel}}" | ||
Value="Check you still remember your payment password"> | ||
<Setter Property="IsVisible" Value="True"/> | ||
</DataTrigger> | ||
</StackLayout.Triggers> | ||
</StackLayout> | ||
|
||
<!--Check you still remember your secret recovery phrase--> | ||
<StackLayout IsVisible="false"> | ||
<Entry x:Name="phraseEntry" | ||
Focused="ClearResult" | ||
IsPassword="true" | ||
Text="" | ||
Placeholder="Type your recovery phrase"/> | ||
|
||
<Grid> | ||
<DatePicker x:Name="dateOfBirthPicker" | ||
Focused="ClearResult" | ||
HorizontalOptions="FillAndExpand" | ||
TextColor="Transparent" | ||
DateSelected="OnDatePickerDateSelected"/> | ||
<Entry x:Name="dateOfBirthLabel" | ||
Placeholder="Choose your date of birth" | ||
BackgroundColor="Transparent" | ||
VerticalOptions="Center" | ||
InputTransparent="True" | ||
IsEnabled="False"/> | ||
</Grid> | ||
|
||
<Entry x:Name="emailEntry" | ||
Focused="ClearResult" | ||
Text="" | ||
Placeholder="Type your email"/> | ||
|
||
<Button Text="Check my secret recovery phrase" | ||
Clicked="OnCheckPasswordButtonClicked" | ||
HorizontalOptions="FillAndExpand"> | ||
<Button.Triggers> | ||
<DataTrigger TargetType="Button" | ||
Binding="{Binding Text.Length, Source={x:Reference emailEntry}}" | ||
Value="0"> | ||
<Setter Property="IsEnabled" Value="False"/> | ||
</DataTrigger> | ||
<DataTrigger TargetType="Button" | ||
Binding="{Binding Text, Source={x:Reference dateOfBirthLabel}}" | ||
Value="Choose your date of birth"> | ||
<Setter Property="IsEnabled" Value="False"/> | ||
</DataTrigger> | ||
<DataTrigger TargetType="Button" | ||
Binding="{Binding Text.Length, Source={x:Reference phraseEntry}}" | ||
Value="0"> | ||
<Setter Property="IsEnabled" Value="False"/> | ||
</DataTrigger> | ||
</Button.Triggers> | ||
</Button> | ||
<StackLayout.Triggers> | ||
<DataTrigger TargetType="StackLayout" | ||
Binding="{Binding Text, Source={x:Reference titleLabel}}" | ||
Value="Check you still remember your secret recovery phrase"> | ||
<Setter Property="IsVisible" Value="True"/> | ||
</DataTrigger> | ||
</StackLayout.Triggers> | ||
</StackLayout> | ||
|
||
<!-- Wipe your current wallet, in order to start from scratch--> | ||
<StackLayout Spacing="10" | ||
IsVisible="false"> | ||
|
||
<Label Text="If you want to remove accounts, the recommended way is to archive them, not wipe the whole wallet." | ||
HorizontalTextAlignment="Center"/> | ||
|
||
<Button Text="I want to do it anyway" | ||
Clicked="OnWipeWalletButtonClicked" | ||
HorizontalOptions="FillAndExpand"> | ||
</Button> | ||
<StackLayout.Triggers> | ||
<DataTrigger TargetType="StackLayout" | ||
Binding="{Binding Text, Source={x:Reference titleLabel}}" | ||
Value="Wipe your current wallet, in order to start from scratch"> | ||
<Setter Property="IsVisible" Value="True"/> | ||
</DataTrigger> | ||
</StackLayout.Triggers> | ||
</StackLayout> | ||
|
||
<!-- Loading & Results --> | ||
<Grid Margin="0,30,0,0"> | ||
<ActivityIndicator IsVisible="False" x:Name="loadingIndicator" IsRunning="True"/> | ||
<Label x:Name="resultMessage" IsVisible="False" HorizontalTextAlignment="Center" Text="Try again"/> | ||
</Grid> | ||
|
||
</StackLayout> | ||
</AbsoluteLayout> | ||
</ContentPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
namespace GWallet.Frontend.XF | ||
|
||
open System | ||
open System.Linq | ||
|
||
open Xamarin.Forms | ||
open Xamarin.Forms.Xaml | ||
open Fsdk | ||
|
||
open GWallet.Backend | ||
|
||
type SettingsPage(option: string) as this = | ||
inherit ContentPage() | ||
let _ = base.LoadFromXaml(typeof<SettingsPage>) | ||
let titleLabel = base.FindByName<Label> "titleLabel" | ||
|
||
//check password | ||
let passwordEntry = base.FindByName<Entry> "passwordEntry" | ||
|
||
//check passphrase | ||
let phraseEntry = base.FindByName<Entry> "phraseEntry" | ||
let emailEntry = base.FindByName<Entry> "emailEntry" | ||
let dateOfBirthPicker = base.FindByName<DatePicker> "dateOfBirthPicker" | ||
let dateOfBirthLabel = base.FindByName<Entry> "dateOfBirthLabel" | ||
|
||
//loading & result | ||
let resultMessage = base.FindByName<Label> "resultMessage" | ||
let loadingIndicator = base.FindByName<ActivityIndicator> "loadingIndicator" | ||
|
||
do | ||
this.Init() | ||
|
||
member self.Init () = | ||
titleLabel.Text <- option | ||
|
||
member self.OnCheckPasswordButtonClicked(_sender: Object, _args: EventArgs) = | ||
this.PerformCheck (Account.CheckValidPassword passwordEntry.Text None) | ||
|
||
member self.OnCheckSeedPassphraseClicked(_sender: Object, _args: EventArgs) = | ||
this.PerformCheck (Account.CheckValidSeed phraseEntry.Text dateOfBirthPicker.Date emailEntry.Text) | ||
|
||
member self.PerformCheck(checkTask: Async<bool>) = | ||
async { | ||
Device.BeginInvokeOnMainThread( | ||
fun () -> | ||
loadingIndicator.IsVisible <- true | ||
resultMessage.IsVisible <- false) | ||
let! checkResult = checkTask | ||
Device.BeginInvokeOnMainThread( | ||
fun () -> | ||
loadingIndicator.IsVisible <- false | ||
resultMessage.IsVisible <- true | ||
resultMessage.Text <- if checkResult then "Success!" else "Try again" ) | ||
} |> FrontendHelpers.DoubleCheckCompletionAsync true | ||
|
||
member self.OnWipeWalletButtonClicked (_sender: Object, _args: EventArgs) = | ||
async { | ||
let! result = Application.Current.MainPage.DisplayAlert("Are you sure?", "Are you ABSOLUTELY SURE about this?", "Yes", "No") |> Async.AwaitTask | ||
if result then | ||
Account.WipeAll() | ||
let displayTask = Application.Current.MainPage.DisplayAlert("Success", "You successfully wiped your current wallet", "Ok") | ||
do! Async.AwaitTask displayTask | ||
|
||
} |> Async.StartImmediate | ||
|
||
member self.OnDatePickerDateSelected (_sender: obj) (evArgs: DateChangedEventArgs) = | ||
dateOfBirthLabel.Text <- evArgs.NewDate.ToString("dd MMMM yyyy") | ||
|
||
member self.ClearResult (_sender: Object, _args: EventArgs) = | ||
resultMessage.IsVisible <- false |