-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Frontend.XF: added the settings icon and side menu #203
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kubaflo question, is there any specific reason of why you used AbsoluteLayout here instead of an non-absolute alternative? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is necessary as I want the 'mainLayout' to occupy 70% of the page's width
|
||
<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> |
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this iOS thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without we wouldn't be able to apply a safe area to the ios version of the app
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is a safe area?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an area where the notch is. Here are the screens how the app would look like without it