RadekVyM / SimpleToolkit

SimpleToolkit is a .NET MAUI library of helpers and simple, fully customizable controls, such as SimpleShell - custom Shell implementation that allows you to create unique navigation experiences.
MIT License
434 stars 44 forks source link

Back Button Not Center #54

Closed raselldev closed 3 months ago

raselldev commented 4 months ago

I have implementation back button, and i have wrong button position.

<simpleShell:SimpleShell.RootPageContainer>
    <Grid
        RowDefinitions="*, 50"
        x:Name="rootContainer">
        <simpleShell:SimpleNavigationHost x:Name="pageContainer"/>
        <controls:TabBarView
            Grid.Row="1"
            ShellItems="{Binding Path=ShellContents, Source={x:Reference thisShell}}"
            VerticalOptions="End" HorizontalOptions="Fill"
            CurrentPageSelectionChanged="TabBarViewCurrentPageChanged"/>
    </Grid>
</simpleShell:SimpleShell.RootPageContainer>

<simpleShell:SimpleShell.Content>
    <Grid
        RowDefinitions="50, *"
        ColumnDefinitions="Auto,*">
        <Button
            x:Name="backButton"
            Text="Back"
            Margin="20,5"
            HorizontalOptions="Start"
            VerticalOptions="Center"
            Background="Black"
            Grid.Column="0"/>
        <Label
            HorizontalOptions="Center"
            VerticalOptions="Center"
            Text="{Binding CurrentShellContent.Title, Source={x:Reference thisShell}}"
            FontAttributes="Bold"
            FontSize="18"
            Grid.Column="1"/>
        <simpleShell:SimpleNavigationHost Grid.Row="1" Grid.ColumnSpan="2"/>
    </Grid>
</simpleShell:SimpleShell.Content>

Whats wrong with my xaml code?

Screenshot 2024-07-11 at 17 23 19
raselldev commented 4 months ago

Updated Code

<simpleShell:SimpleShell.RootPageContainer>
        <Grid
            RowDefinitions="*, Auto"
            x:Name="rootContainer">
            <controls:TopBarScaffold
                IsBackButtonVisible="False"
                Title="{Binding CurrentShellContent.Title, Source={x:Reference thisShell}}">
                <simpleShell:SimpleNavigationHost x:Name="pageContainer"/>
            </controls:TopBarScaffold>

            <controls:TabBarView
                Grid.Row="1"
                ShellItems="{Binding Path=ShellContents, Source={x:Reference thisShell}}"
                VerticalOptions="End" HorizontalOptions="Fill"
                CurrentPageSelectionChanged="TabBarViewCurrentPageChanged"/>
        </Grid>
    </simpleShell:SimpleShell.RootPageContainer>
TopBarScafold.xaml

   ```
RadekVyM commented 4 months ago

Hi @raselldev,

what is the expected position of the button?

raselldev commented 3 months ago

Hi @RadekVyM thank you for your reply,

expected like this video in simpleshell:

ios: https://github.com/RadekVyM/SimpleToolkit/assets/65116078/84cf922e-f698-4f96-b06c-561df5c61e1c

android: https://github.com/RadekVyM/SimpleToolkit/assets/65116078/b37e1561-be40-4aef-a255-060cfbfc9572

i just updated with your code in https://github.com/RadekVyM/SimpleToolkit/blob/main/docs/SimpleToolkit.SimpleShell/README.md but not working

delete bin & obj still not working.

raselldev commented 3 months ago

AppShell.xaml

```
``` AppShell.cs ``` public partial class AppShell : SimpleShell { public AppShell() { InitializeComponent(); Loaded += AppShellLoaded; Routing.RegisterRoute(nameof(DetailInboxPage), typeof(DetailInboxPage)); } private static void AppShellLoaded(object sender, EventArgs e) { var shell = sender as AppShell; shell.Window.SubscribeToSafeAreaChanges(safeArea => { shell.rootContainer.Margin = new Thickness(safeArea.Left, safeArea.Top / 1.2, safeArea.Right, safeArea.Bottom); shell.rootContainer.Padding = new Thickness(safeArea.Left, safeArea.Top / 1.2, safeArea.Right, safeArea.Bottom); }); } private void TabBarViewCurrentPageChanged(object sender, TabBarEventArgs e) { Shell.Current.GoToAsync("///" + e.CurrentPage.ToString()); } } ``` TopBarScafold.xaml ```
RadekVyM commented 3 months ago

Hi,

these code snippets do not help me to understand where the problem is. If the information bellow does not help, could you please create a GitHub repository with a reproduction sample and share it?

The sample used in the SimpleShell documentation does not use the DisplayContentBehindBars() method that extends app's content outside the safe areas (behind status and navigation bars). If you do not need this feature, do not call that method in CreateMauiApp().

If I am not mistaken, basically all samples listed in the Samples section of this repository use safe area helpers.

raselldev commented 3 months ago

@RadekVyM

It's work with remove DisplayContentBehindBars()

Thank you for your support!!