MobileToolGrid.xaml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <ContentView xmlns="http://xamarin.com/schemas/2014/forms"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
  4. xmlns:local="clr-namespace:InABox.Mobile"
  5. x:Class="InABox.Mobile.MobileToolGrid">
  6. <ContentView.Resources>
  7. <local:BooleanToColorConverter x:Key="BooleanToColorConverter" TrueColor="LightSalmon" FalseColor="LightGoldenrodYellow"/>
  8. </ContentView.Resources>
  9. <ContentView.BindingContext>
  10. <local:ToolGridViewModel x:Name="_viewModel" LayoutChanged="_viewModel_OnLayoutChanged"/>
  11. </ContentView.BindingContext>
  12. <ContentView.Content>
  13. <ScrollView>
  14. <Grid RowSpacing="5" ColumnSpacing="5"
  15. x:Name="_flexgrid"
  16. BindableLayout.ItemsSource = "{Binding Items}"
  17. HorizontalOptions="Fill"
  18. VerticalOptions="StartAndExpand"
  19. >
  20. <BindableLayout.ItemTemplate>
  21. <DataTemplate x:DataType="local:MobileToolItem">
  22. <Grid
  23. Margin="0"
  24. Grid.Row="{Binding Row}"
  25. Grid.Column="{Binding Column}"
  26. IsVisible="True"
  27. VerticalOptions="Fill"
  28. HorizontalOptions="Fill">
  29. <Grid.ColumnDefinitions>
  30. <ColumnDefinition Width="*"/>
  31. </Grid.ColumnDefinitions>
  32. <Grid.RowDefinitions>
  33. <RowDefinition Height="Auto"/>
  34. <!-- <RowDefinition Height="15"/> -->
  35. </Grid.RowDefinitions>
  36. <Frame
  37. CornerRadius="5"
  38. HasShadow="False"
  39. Margin="0"
  40. x:Name="toolFrame"
  41. Grid.Row="0"
  42. Grid.Column="0"
  43. BorderColor="{Binding Source={RelativeSource AncestorType={x:Type local:MobileToolGrid}}, Path=BorderColor}"
  44. HeightRequest="{Binding Source={RelativeSource Self}, Path=Width}"
  45. BackgroundColor="{Binding AlertVisible, Converter={StaticResource BooleanToColorConverter}}"
  46. Padding="0">
  47. <Frame.Triggers>
  48. <DataTrigger TargetType="Frame" Binding="{Binding IsEnabled}" Value="False">
  49. <Setter Property="BackgroundColor" Value="LightGray" />
  50. <Setter Property="BorderColor" Value="Gray" />
  51. </DataTrigger>
  52. </Frame.Triggers>
  53. <Frame.GestureRecognizers>
  54. <TapGestureRecognizer Tapped="ToolItem_Tapped" />
  55. </Frame.GestureRecognizers>
  56. <Grid RowSpacing="0" ColumnSpacing="0">
  57. <Grid.RowDefinitions>
  58. <RowDefinition Height="Auto"/>
  59. <RowDefinition Height="*"/>
  60. <RowDefinition Height="Auto"/>
  61. </Grid.RowDefinitions>
  62. <Grid.ColumnDefinitions>
  63. <ColumnDefinition Width="Auto"/>
  64. <ColumnDefinition Width="*"/>
  65. </Grid.ColumnDefinitions>
  66. <Image
  67. x:Name="toolEntryImage"
  68. Grid.Row="0"
  69. Grid.Column="0"
  70. Grid.ColumnSpan="2"
  71. Grid.RowSpan="2"
  72. Source="{Binding Image}">
  73. <Image.Margin>
  74. <OnIdiom x:TypeArguments="Thickness">
  75. <OnIdiom.Phone>
  76. <OnPlatform x:TypeArguments="Thickness">
  77. <On Platform="iOS" Value="15,0"/>
  78. <On Platform="Android" Value="15,0"/>
  79. </OnPlatform>
  80. </OnIdiom.Phone>
  81. <OnIdiom.Tablet>
  82. <OnPlatform x:TypeArguments="Thickness">
  83. <On Platform="iOS" Value="30,15"/>
  84. <On Platform="Android" Value="30,15"/>
  85. </OnPlatform>
  86. </OnIdiom.Tablet>
  87. </OnIdiom>
  88. </Image.Margin>
  89. </Image>
  90. <Frame
  91. x:Name="indicatorFrame"
  92. Grid.Row="0"
  93. Grid.Column="1"
  94. HasShadow="False"
  95. VerticalOptions="Start"
  96. HorizontalOptions="End"
  97. CornerRadius="10"
  98. IsVisible="{Binding AlertVisible}"
  99. BackgroundColor="Yellow"
  100. BorderColor="Orange"
  101. Padding="0"
  102. Margin="4"
  103. HeightRequest="20"
  104. WidthRequest="20">
  105. <Label
  106. FontAttributes="Bold"
  107. TextColor="Red"
  108. FontSize="9"
  109. HorizontalTextAlignment="Center"
  110. VerticalTextAlignment="Center"
  111. Text="{Binding Alert}"
  112. WidthRequest="{Binding Source={RelativeSource Self}, Path=Height}"/>
  113. </Frame>
  114. <Label
  115. Grid.Row="2"
  116. Grid.Column="0"
  117. Grid.ColumnSpan="2"
  118. Text="{Binding Text}"
  119. FontSize="Micro"
  120. Margin="0,0,0,5"
  121. HorizontalTextAlignment="Center"
  122. VerticalTextAlignment="Start"
  123. TextColor="{Binding TextColor}">
  124. <Label.Triggers>
  125. <DataTrigger TargetType="Label" Binding="{Binding IsEnabled}" Value="False">
  126. <Setter Property="TextColor" Value="Gray" />
  127. </DataTrigger>
  128. </Label.Triggers>
  129. </Label>
  130. </Grid>
  131. </Frame>
  132. </Grid>
  133. </DataTemplate>
  134. </BindableLayout.ItemTemplate>
  135. </Grid>
  136. </ScrollView>
  137. </ContentView.Content>
  138. </ContentView>