Skip to content
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

Replace circle chart by hoop chart #234

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 3 additions & 50 deletions src/GWallet.Frontend.XF/BalancesPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,58 +14,11 @@
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand">

<!-- we add {V|H}Options=Center* not only to the Label, as a workaround to
https://github.com/xamarin/Xamarin.Forms/issues/4655 -->
<Frame x:Name="totalFiatAmountFrame"
HasShadow="false"
BackgroundColor="Transparent"
BorderColor="Transparent"
VerticalOptions="CenterAndExpand"
HorizontalOptions="End"
Padding="0"
Margin="0,0,0,0">
<StackLayout x:Name="totalFiatAmountLayout"
Orientation="Horizontal"
VerticalOptions="CenterAndExpand"
HorizontalOptions="Center"
Margin="0,0,0,0">
<Label Text="..." x:Name="totalFiatAmountLabel"
VerticalOptions="CenterAndExpand"
HorizontalOptions="Center"
Margin="0,0,0,0"
FontSize="22" />
</StackLayout>
</Frame>

<!-- keep this frame&stacklayout&label below almost same as previous! -->
<Frame x:Name="totalReadOnlyFiatAmountFrame"
HasShadow="false"
IsVisible="false"
BackgroundColor="Transparent"
BorderColor="Transparent"
VerticalOptions="CenterAndExpand"
HorizontalOptions="End"
Padding="0"
Margin="0,0,0,0">
<StackLayout x:Name="totalReadOnlyFiatAmountLayout"
Orientation="Horizontal"
VerticalOptions="CenterAndExpand"
HorizontalOptions="Center"
Margin="0,0,0,0">
<Label Text="..." x:Name="totalReadOnlyFiatAmountLabel"
VerticalOptions="CenterAndExpand"
HorizontalOptions="Center"
Margin="0,0,0,0"
FontSize="22"
TextColor="DarkBlue" />
</StackLayout>
</Frame>

<controls:CircleChartView x:Name="normalChartView"
<controls:HoopChartView x:Name="normalChartView"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"/>
<controls:CircleChartView x:Name="readonlyChartView"

<controls:HoopChartView x:Name="readonlyChartView"
IsVisible="False"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"/>
Expand Down
48 changes: 14 additions & 34 deletions src/GWallet.Frontend.XF/BalancesPage.xaml.fs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ type BalancesPage(state: FrontendHelpers.IGlobalAppState,
let normalAccountsBalanceSets = normalBalanceStates.Select(fun balState -> balState.BalanceSet)
let readOnlyAccountsBalanceSets = readOnlyBalanceStates.Select(fun balState -> balState.BalanceSet)
let mainLayout = base.FindByName<StackLayout>("mainLayout")
let totalFiatAmountLabel = mainLayout.FindByName<Label> "totalFiatAmountLabel"
let totalReadOnlyFiatAmountLabel = mainLayout.FindByName<Label> "totalReadOnlyFiatAmountLabel"
let contentLayout = base.FindByName<StackLayout> "contentLayout"
let normalChartView = base.FindByName<CircleChartView> "normalChartView"
let readonlyChartView = base.FindByName<CircleChartView> "readonlyChartView"
let normalChartView = base.FindByName<HoopChartView> "normalChartView"
let readonlyChartView = base.FindByName<HoopChartView> "readonlyChartView"

let standardTimeToRefreshBalances = TimeSpan.FromMinutes 5.0
let standardTimeToRefreshBalancesWhenThereIsImminentIncomingPaymentOrNotEnoughInfoToKnow = TimeSpan.FromMinutes 1.0
Expand Down Expand Up @@ -74,7 +72,7 @@ type BalancesPage(state: FrontendHelpers.IGlobalAppState,
(Formatting.DecimalAmountRounding CurrencyType.Fiat atLeastAmount)
(FrontendHelpers.MaybeReturnOutdatedMarkForOldDate time)

totalFiatAmountLabel.Text <- SPrintF1 "Total Assets:\n%s" strBalance
totalFiatAmountLabel.Text <- strBalance

let rec UpdateGlobalFiatBalance (acc: Option<MaybeCached<TotalBalance>>)
(fiatBalances: List<MaybeCached<decimal>>)
Expand Down Expand Up @@ -163,18 +161,12 @@ type BalancesPage(state: FrontendHelpers.IGlobalAppState,
readonlyChartView
else
normalChartView
let fullAmount = balances.Sum(fun b -> GetAmountOrDefault b.FiatAmount)


let chartSourceList =
balances |> Seq.map (fun balanceState ->
let percentage =
if fullAmount = 0m then
0m
else
GetAmountOrDefault balanceState.FiatAmount / fullAmount
{
Color = FrontendHelpers.GetCryptoColor balanceState.BalanceSet.Account.Currency
Percentage = float(percentage)
Amount = GetAmountOrDefault balanceState.FiatAmount
}
)
chartView.SegmentsSource <- chartSourceList
Expand Down Expand Up @@ -300,7 +292,7 @@ type BalancesPage(state: FrontendHelpers.IGlobalAppState,
None

let readOnlyAccountsBalanceUpdate =
self.UpdateGlobalBalance readOnlyBalancesJob totalReadOnlyFiatAmountLabel true
self.UpdateGlobalBalance readOnlyBalancesJob readonlyChartView.BalanceLabel true

let allCancelSources,allBalanceUpdates =
if (not onlyReadOnlyAccounts) then
Expand All @@ -311,7 +303,7 @@ type BalancesPage(state: FrontendHelpers.IGlobalAppState,
None

let normalAccountsBalanceUpdate =
self.UpdateGlobalBalance normalBalancesJob totalFiatAmountLabel false
self.UpdateGlobalBalance normalBalancesJob normalChartView.BalanceLabel false

let allCancelSources = Seq.append readOnlyCancelSources normalCancelSources

Expand Down Expand Up @@ -387,12 +379,6 @@ type BalancesPage(state: FrontendHelpers.IGlobalAppState,
cancelSource.Dispose()

member private self.ConfigureFiatAmountFrame (readOnly: bool): TapGestureRecognizer =
let totalCurrentFiatAmountFrameName,totalOtherFiatAmountFrameName =
if readOnly then
"totalReadOnlyFiatAmountFrame","totalFiatAmountFrame"
else
"totalFiatAmountFrame","totalReadOnlyFiatAmountFrame"

let currentChartViewName,otherChartViewName =
if readOnly then
"readonlyChartView","normalChartView"
Expand All @@ -401,13 +387,9 @@ type BalancesPage(state: FrontendHelpers.IGlobalAppState,

let switchingToReadOnly = not readOnly

let totalCurrentFiatAmountFrame,totalOtherFiatAmountFrame =
mainLayout.FindByName<Frame> totalCurrentFiatAmountFrameName,
mainLayout.FindByName<Frame> totalOtherFiatAmountFrameName

let currentChartView,otherChartView =
mainLayout.FindByName<CircleChartView> currentChartViewName,
mainLayout.FindByName<CircleChartView> otherChartViewName
mainLayout.FindByName<HoopChartView> currentChartViewName,
mainLayout.FindByName<HoopChartView> otherChartViewName

let tapGestureRecognizer = TapGestureRecognizer()
tapGestureRecognizer.Tapped.Add(fun _ ->
Expand All @@ -420,9 +402,7 @@ type BalancesPage(state: FrontendHelpers.IGlobalAppState,

if shouldNotOpenNewPage then
MainThread.BeginInvokeOnMainThread(fun _ ->
totalCurrentFiatAmountFrame.IsVisible <- false
currentChartView.IsVisible <- false
totalOtherFiatAmountFrame.IsVisible <- true
otherChartView.IsVisible <- true
)
let balancesStatesToPopulate =
Expand Down Expand Up @@ -459,7 +439,7 @@ type BalancesPage(state: FrontendHelpers.IGlobalAppState,
FrontendHelpers.SwitchToNewPage self page true

)
totalCurrentFiatAmountFrame.GestureRecognizers.Add tapGestureRecognizer
currentChartView.BalanceFrame.GestureRecognizers.Add tapGestureRecognizer
tapGestureRecognizer

member self.PopulateGridInitially () =
Expand All @@ -477,11 +457,11 @@ type BalancesPage(state: FrontendHelpers.IGlobalAppState,
let labels,color =
if readOnly then
let color = Color.DarkBlue
totalReadOnlyFiatAmountLabel.TextColor <- color
readonlyChartView.BalanceLabel.TextColor <- color
readOnlyAccountsBalanceSets,color
else
let color = Color.DarkRed
totalFiatAmountLabel.TextColor <- color
normalChartView.BalanceLabel.TextColor <- color
normalAccountsBalanceSets,color

for balanceSet in labels do
Expand Down Expand Up @@ -522,8 +502,8 @@ type BalancesPage(state: FrontendHelpers.IGlobalAppState,

self.PopulateGridInitially ()

self.UpdateGlobalFiatBalanceSum allNormalAccountFiatBalances totalFiatAmountLabel
self.UpdateGlobalFiatBalanceSum allReadOnlyAccountFiatBalances totalReadOnlyFiatAmountLabel
self.UpdateGlobalFiatBalanceSum allNormalAccountFiatBalances normalChartView.BalanceLabel
self.UpdateGlobalFiatBalanceSum allReadOnlyAccountFiatBalances readonlyChartView.BalanceLabel
)

self.RefreshBalances true |> FrontendHelpers.DoubleCheckCompletionAsync false
Expand Down
199 changes: 0 additions & 199 deletions src/GWallet.Frontend.XF/Controls/CircleChartView.fs

This file was deleted.

Loading
Loading