-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTipCalcPage.xaml
55 lines (55 loc) · 3.26 KB
/
TipCalcPage.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:tipCalc="clr-namespace:TipCalc;assembly=TipCalc"
x:Class="TipCalc.TipCalcPage">
<ContentPage.Padding>
<OnPlatform x:TypeArguments="Thickness">
<On Platform="iOS">10, 80, 10, 0</On>
<On Platform="Android">5, 0, 5, 0</On>
<On Platform="UWP">5, 0, 5, 0</On>
</OnPlatform>
</ContentPage.Padding>
<ContentPage.Resources>
<ResourceDictionary>
<tipCalc:TipCalcModel x:Key="model" TipPercent="15" />
<tipCalc:DoubleToStringConverter x:Key="stringConverter" />
<tipCalc:DoubleRoundingConverter x:Key="roundConverter" />
</ResourceDictionary>
</ContentPage.Resources>
<Grid BindingContext="{StaticResource model}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Row 0 -->
<Label Text="Food & Drink:" Grid.Row="0" Grid.Column="0" HorizontalTextAlignment="End" VerticalTextAlignment="Center" />
<Entry Grid.Row="0" Grid.Column="1" Keyboard="Numeric" Placeholder="Subtotal" Text="{Binding SubTotal, Converter={StaticResource stringConverter}}" />
<!-- Row 1 -->
<Label Text="Total after Tax:" Grid.Row="1" Grid.Column="0" HorizontalTextAlignment="End" VerticalTextAlignment="Center" />
<Entry Grid.Row="1" Grid.Column="1" Keyboard="Numeric" Placeholder="Receipt total" Text="{Binding PostTaxTotal, Converter={StaticResource stringConverter}}" />
<!-- Row 2 -->
<Label Text="Tip Percent:" Grid.Row="2" Grid.Column="0" HorizontalTextAlignment="End" VerticalTextAlignment="Center" />
<Entry Grid.Row="2" Grid.Column="1" Keyboard="Numeric" Text="{Binding TipPercent, Converter={StaticResource stringConverter}}" />
<!-- Row 3 -->
<Slider Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Minimum="0" Maximum="100" Value="{Binding TipPercent, Mode=TwoWay, Converter={StaticResource roundConverter}, ConverterParameter=0.5}" />
<!-- Row 4 -->
<Label Text="Tip Amount:" Grid.Row="4" Grid.Column="0" HorizontalTextAlignment="End" VerticalTextAlignment="Center" />
<ContentView BackgroundColor="#40808080" Grid.Row="4" Grid.Column="1" Padding="10, 10, 40, 10">
<Label Text="{Binding TipAmount, StringFormat='{0:C}'}" HorizontalTextAlignment="End" />
</ContentView>
<!-- Row 5 -->
<Label Text="Total:" Grid.Row="5" Grid.Column="0" HorizontalTextAlignment="End" VerticalTextAlignment="Center" />
<ContentView BackgroundColor="#40808080" Grid.Row="5" Grid.Column="1" Padding="10, 10, 40, 10">
<Label Text="{Binding Total, StringFormat='{0:C}'}" HorizontalTextAlignment="End" />
</ContentView>
</Grid>
</ContentPage>