MobileToolGrid.xaml 8.3 KB

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