Skip to content

Commit

Permalink
Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
naweed committed Jul 23, 2022
1 parent 010798c commit 69ba8a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 36 deletions.
7 changes: 5 additions & 2 deletions src/Maui.Controls.BottomSheet/BottomSheet.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
x:Class="XGENO.Maui.Controls.BottomSheet"
InputTransparent="True"
VerticalOptions="Fill"
x:Name="BottomSheetControlRoot"
HorizontalOptions="Fill">

<ContentView.Resources>
Expand All @@ -30,7 +31,7 @@

<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition x:Name="BottomSheetRowDefinition" Height="360" />
<RowDefinition x:Name="BottomSheetRowDefinition" Height="{Binding Source={x:Reference BottomSheetControlRoot}, Path=SheetHeight, Mode=OneWay}" />
</Grid.RowDefinitions>

<!-- Close Button -->
Expand Down Expand Up @@ -60,7 +61,7 @@
VerticalOptions="Fill"
HorizontalOptions="Fill"
StrokeThickness="0"
TranslationY="360">
TranslationY="{Binding Source={x:Reference BottomSheetControlRoot}, Path=SheetHeight, Mode=OneWay}">

<Border.StrokeShape>
<RoundRectangle CornerRadius="32,32,0,0"/>
Expand All @@ -73,6 +74,8 @@
<!-- Header Content -->
<Label
x:Name="HeaderLabel"
Style="{Binding Source={x:Reference BottomSheetControlRoot}, Path=HeaderStyle, Mode=OneWay}"
Text="{Binding Source={x:Reference BottomSheetControlRoot}, Path=HeaderText, Mode=OneWay}"
Grid.Row="0"
HorizontalOptions="Center"
VerticalOptions="Center"
Expand Down
43 changes: 9 additions & 34 deletions src/Maui.Controls.BottomSheet/BottomSheet.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,7 @@ public partial class BottomSheet : ContentView
typeof(BottomSheet),
360d,
BindingMode.OneWay,
validateValue: (_, value) => value != null,
propertyChanged:
(bindableObject, oldValue, newValue) =>
{
if (newValue is not null && bindableObject is BottomSheet sheet && newValue != oldValue)
{
sheet.BottomSheetRowDefinition.Height = ((double)newValue);
sheet.MainContent.TranslationY = ((double)newValue);
}
});
validateValue: (_, value) => value != null);

public double SheetHeight
{
Expand All @@ -40,15 +31,7 @@ public double SheetHeight
typeof(BottomSheet),
string.Empty,
BindingMode.OneWay,
validateValue: (_, value) => value != null,
propertyChanged:
(bindableObject, oldValue, newValue) =>
{
if (newValue is not null && bindableObject is BottomSheet sheet && newValue != oldValue)
{
sheet.HeaderLabel.Text = ((string)newValue);
}
});
validateValue: (_, value) => value != null);

public string HeaderText
{
Expand All @@ -62,15 +45,7 @@ public string HeaderText
typeof(BottomSheet),
null,
BindingMode.OneWay,
validateValue: (_, value) => value != null,
propertyChanged:
(bindableObject, oldValue, newValue) =>
{
if (newValue is not null && bindableObject is BottomSheet sheet && newValue != oldValue)
{
sheet.HeaderLabel.Style = ((Style)newValue);
}
});
validateValue: (_, value) => value != null);

public Style HeaderStyle
{
Expand All @@ -94,18 +69,18 @@ public Style HeaderStyle
}
});

private void UpdateTheme()
{
MainContent.BackgroundColor = Color.FromArgb(Theme == DisplayTheme.Dark ? "#333333" : "#FFFFFF");
MainContent.Stroke = Color.FromArgb(Theme == DisplayTheme.Dark ? "#333333" : "#FFFFFF");
}

public DisplayTheme Theme
{
get => (DisplayTheme)GetValue(ThemeProperty);
set => SetValue(ThemeProperty, value);
}

private void UpdateTheme()
{
MainContent.BackgroundColor = Color.FromArgb(Theme == DisplayTheme.Dark ? "#333333" : "#FFFFFF");
MainContent.Stroke = Color.FromArgb(Theme == DisplayTheme.Dark ? "#333333" : "#FFFFFF");
}

#endregion

public BottomSheet()
Expand Down

0 comments on commit 69ba8a2

Please sign in to comment.