MobileToolGrid.xaml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. </DataTrigger>
  51. <DataTrigger TargetType="Frame" Binding="{Binding AlertVisible}" Value="True">
  52. <Setter Property="BackgroundColor" Value="LightSalmon" />
  53. </DataTrigger>
  54. </Frame.Triggers>
  55. <Frame.GestureRecognizers>
  56. <TapGestureRecognizer Tapped="ToolItem_Tapped" />
  57. </Frame.GestureRecognizers>
  58. <Grid RowSpacing="0" ColumnSpacing="0">
  59. <Grid.RowDefinitions>
  60. <RowDefinition Height="Auto"/>
  61. <RowDefinition Height="*"/>
  62. <RowDefinition Height="Auto"/>
  63. </Grid.RowDefinitions>
  64. <Grid.ColumnDefinitions>
  65. <ColumnDefinition Width="Auto"/>
  66. <ColumnDefinition Width="*"/>
  67. </Grid.ColumnDefinitions>
  68. <Image
  69. x:Name="toolEntryImage"
  70. Grid.Row="0"
  71. Grid.Column="0"
  72. Grid.ColumnSpan="2"
  73. Grid.RowSpan="2"
  74. Source="{Binding Image}">
  75. <Image.Margin>
  76. <OnIdiom x:TypeArguments="Thickness">
  77. <OnIdiom.Phone>
  78. <OnPlatform x:TypeArguments="Thickness">
  79. <On Platform="iOS" Value="15,0"/>
  80. <On Platform="Android" Value="15,0"/>
  81. </OnPlatform>
  82. </OnIdiom.Phone>
  83. <OnIdiom.Tablet>
  84. <OnPlatform x:TypeArguments="Thickness">
  85. <On Platform="iOS" Value="30,15"/>
  86. <On Platform="Android" Value="30,15"/>
  87. </OnPlatform>
  88. </OnIdiom.Tablet>
  89. </OnIdiom>
  90. </Image.Margin>
  91. </Image>
  92. <Frame
  93. x:Name="indicatorFrame"
  94. Grid.Row="0"
  95. Grid.Column="1"
  96. HasShadow="False"
  97. VerticalOptions="Start"
  98. HorizontalOptions="End"
  99. CornerRadius="10"
  100. IsVisible="{Binding AlertVisible}"
  101. BackgroundColor="Yellow"
  102. BorderColor="{Binding Source={RelativeSource AncestorType={x:Type local:MobileToolGrid}}, Path=BorderColor}"
  103. Padding="0"
  104. Margin="4"
  105. HeightRequest="20"
  106. WidthRequest="20">
  107. <Label
  108. FontAttributes="Bold"
  109. TextColor="Red"
  110. FontSize="9"
  111. HorizontalTextAlignment="Center"
  112. VerticalTextAlignment="Center"
  113. Text="{Binding Alert}"
  114. WidthRequest="{Binding Source={RelativeSource Self}, Path=Height}"/>
  115. </Frame>
  116. <Label
  117. Grid.Row="2"
  118. Grid.Column="0"
  119. Grid.ColumnSpan="2"
  120. Text="{Binding Text}"
  121. FontSize="Micro"
  122. Margin="0,0,0,5"
  123. HorizontalTextAlignment="Center"
  124. VerticalTextAlignment="Start"
  125. TextColor="{Binding TextColor}">
  126. <Label.Triggers>
  127. <DataTrigger TargetType="Label" Binding="{Binding IsEnabled}" Value="False">
  128. <Setter Property="TextColor" Value="Gray" />
  129. </DataTrigger>
  130. </Label.Triggers>
  131. </Label>
  132. </Grid>
  133. </Frame>
  134. </Grid>
  135. </DataTemplate>
  136. </BindableLayout.ItemTemplate>
  137. </Grid>
  138. </ScrollView>
  139. </ContentView.Content>
  140. </ContentView>