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