MobileToolGrid.xaml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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:MobileMobileToolItem">
  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 HasIndicator, 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. <Grid RowSpacing="0" ColumnSpacing="0">
  54. <Grid.RowDefinitions>
  55. <RowDefinition Height="Auto"/>
  56. <RowDefinition Height="*"/>
  57. <RowDefinition Height="Auto"/>
  58. </Grid.RowDefinitions>
  59. <Grid.ColumnDefinitions>
  60. <ColumnDefinition Width="Auto"/>
  61. <ColumnDefinition Width="*"/>
  62. </Grid.ColumnDefinitions>
  63. <Image
  64. x:Name="toolEntryImage"
  65. Grid.Row="0"
  66. Grid.Column="0"
  67. Grid.ColumnSpan="2"
  68. Grid.RowSpan="2"
  69. Margin="15,0"
  70. Source="{Binding Image}">
  71. <Image.GestureRecognizers>
  72. <TapGestureRecognizer Tapped="ImageTapped" />
  73. </Image.GestureRecognizers>
  74. </Image>
  75. <Frame
  76. x:Name="indicatorFrame"
  77. Grid.Row="0"
  78. Grid.Column="1"
  79. HasShadow="False"
  80. VerticalOptions="Start"
  81. HorizontalOptions="End"
  82. CornerRadius="10"
  83. IsVisible="{Binding HasIndicator}"
  84. BackgroundColor="Yellow"
  85. BorderColor="Orange"
  86. Padding="0"
  87. Margin="4"
  88. HeightRequest="20">
  89. <Label
  90. FontAttributes="Bold"
  91. TextColor="Red"
  92. FontSize="Micro"
  93. VerticalOptions="Center"
  94. HorizontalTextAlignment="Center"
  95. HorizontalOptions="End"
  96. Margin="3,1,3,0"
  97. Text="{Binding Indicator}"
  98. WidthRequest="{Binding Source={RelativeSource Self}, Path=Height}"/>
  99. </Frame>
  100. <Label
  101. Grid.Row="2"
  102. Grid.Column="0"
  103. Grid.ColumnSpan="2"
  104. Text="{Binding Text}"
  105. FontSize="Micro"
  106. Margin="0,0,0,5"
  107. HorizontalTextAlignment="Center"
  108. VerticalTextAlignment="Start"
  109. TextColor="{Binding TextColor}">
  110. <Label.Triggers>
  111. <DataTrigger TargetType="Label" Binding="{Binding IsEnabled}" Value="False">
  112. <Setter Property="TextColor" Value="Gray" />
  113. </DataTrigger>
  114. </Label.Triggers>
  115. </Label>
  116. </Grid>
  117. </Frame>
  118. </Grid>
  119. </DataTemplate>
  120. </BindableLayout.ItemTemplate>
  121. </Grid>
  122. </ScrollView>
  123. </ContentView.Content>
  124. </ContentView>