Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,36 +84,53 @@

<Label Text="Slide to change StatusBar color" />

<Label Text="Red" />
<Slider
Margin="20,10"
Margin="20,0"
Maximum="255"
MaximumTrackColor="Red"
Minimum="0"
MinimumTrackColor="Red"
ThumbColor="Red"
Value="{Binding RedSliderValue}" />

<Label Text="Green" />
<Slider
Margin="20,10"
Margin="20,0"
Maximum="255"
MaximumTrackColor="Green"
Minimum="0"
MinimumTrackColor="Green"
ThumbColor="Green"
Value="{Binding GreenSliderValue}" />

<Label Text="Blue" />
<Slider
Margin="20,10"
Margin="20,0"
Maximum="255"
MaximumTrackColor="Blue"
Minimum="0"
MinimumTrackColor="Blue"
ThumbColor="Blue"
Value="{Binding BlueSliderValue}" />
<HorizontalStackLayout>
<Label Text="Alpha: " />
<Label Text="{Binding AlphaSliderValue}"/>
</HorizontalStackLayout>

<Stepper
HorizontalOptions="Start"
Margin="20,0"
Maximum="1"
Increment="0.1"
Minimum="0"
Value="{Binding AlphaSliderValue}" />

<VerticalStackLayout Spacing="15">
<Label Text="Select StatusBar and NavigationBar style" />

<HorizontalStackLayout Spacing="15">

<Label Text="Select StatusBar and NavigationBar style" />


<RadioButton VerticalOptions="Center" IsChecked="{Binding IsDefaultChecked}">
<RadioButton.Content>
Expand All @@ -135,7 +152,7 @@
</RadioButton.Content>
</RadioButton>

</VerticalStackLayout>
</HorizontalStackLayout>
</VerticalStackLayout>
</ScrollView>
</pages:BasePage>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ protected override void OnNavigatedTo(NavigatedToEventArgs args)
{
base.OnNavigatedTo(args);

var statusBarColor = Color.FromRgb(BindingContext.RedSliderValue, BindingContext.GreenSliderValue, BindingContext.BlueSliderValue);
var statusBarColor = Color.FromRgba(BindingContext.RedSliderValue, BindingContext.GreenSliderValue, BindingContext.BlueSliderValue, 1.0);
CommunityToolkit.Maui.Core.Platform.StatusBar.SetColor(statusBarColor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ public partial class StatusBarBehaviorViewModel : BaseViewModel
[NotifyPropertyChangedFor(nameof(StatusBarColor))]
int redSliderValue, greenSliderValue, blueSliderValue;

[ObservableProperty]
[NotifyPropertyChangedFor(nameof(StatusBarColor))]
double alphaSliderValue = 1;

[ObservableProperty]
[NotifyPropertyChangedFor(nameof(StatusBarStyle))]
bool isLightContentChecked, isDarkContentChecked, isDefaultChecked = true;

public Color StatusBarColor => Color.FromRgb(RedSliderValue, GreenSliderValue, BlueSliderValue);
public Color StatusBarColor => Color.FromRgba(RedSliderValue, GreenSliderValue, BlueSliderValue, AlphaSliderValue);

public StatusBarStyle StatusBarStyle
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ static void PlatformSetColor(Color color)
{
if (IsSupported())
{
Activity.Window?.SetStatusBarColor(color.ToPlatform());
if (Activity.Window is not null)
{
Activity.Window.SetStatusBarColor(color.ToPlatform());
bool isColorTransparent = color.ToPlatform() == Android.Graphics.Color.Transparent;
Comment thread
vhugogarcia marked this conversation as resolved.
Outdated
WindowCompat.SetDecorFitsSystemWindows(Activity.Window, !isColorTransparent);
}
}
}

Expand Down