Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handler not showing #123

Open
Shubhampandharpote23 opened this issue Jun 18, 2024 · 1 comment
Open

handler not showing #123

Shubhampandharpote23 opened this issue Jun 18, 2024 · 1 comment

Comments

@Shubhampandharpote23
Copy link

<the49:BottomSheet xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ChangeBoxMobileApp.Views.FilterBottomSheet"
xmlns:viewModels="clr-namespace:ChangeBoxMobileApp.ViewModels"
x:DataType="viewModels:TransactionFilterViewModel"
xmlns:the49="https://schemas.the49.com/dotnet/2023/maui"
BackgroundColor="Transparent"
Dismissed="FilterBottomSheet_OnDismissed"
x:Name="BottomSheet">
the49:BottomSheet.Detents
<the49:FullscreenDetent IsDefault="True" />
<the49:ContentDetent />
</the49:BottomSheet.Detents>
the49:BottomSheet.Handler/


            <VerticalStackLayout>

                <Label Text="Select Date Range"
                       FontAttributes="Bold"
                       FontSize="Medium"
                       Margin="0,20,0,0" />

                <Label Text="Start Date"
                       Margin="0,20,0,0"
                       FontAttributes="Bold"
                       FontSize="Small" />

                <HorizontalStackLayout Margin="-5,0,0,10"
                                       Padding="5"
                                       Spacing="10">

                    <StackLayout>

                        <Frame CornerRadius="15"
                               BorderColor="Gray"
                               Padding="5"
                               WidthRequest="100"
                               HeightRequest="45">
                            <HorizontalStackLayout>
                                <Picker x:Name="StartDayPicker"
                                        Title="Day"
                                        HeightRequest="40"
                                        ItemsSource="{Binding StartDayPicker}"
                                        SelectedIndex="{Binding SelectedStartDayIndex}"
                                        Margin="10,0,0,0">
                                </Picker>
                                <Label Text="&#x25BC;"
                                       VerticalOptions="Center" />
                            </HorizontalStackLayout>
                        </Frame>
                    </StackLayout>

                    <StackLayout>
                        <Frame CornerRadius="15"
                               BorderColor="Gray"
                               Padding="5"
                               WidthRequest="100"
                               HeightRequest="45">
                            <HorizontalStackLayout>
                                <Picker x:Name="StartMonthPicker"
                                        Title="Month"
                                        HeightRequest="40"
                                        Margin="10,0,0,0"
                                        ItemsSource="{Binding StartMonthPicker}"
                                        SelectedIndex="{Binding SelectedStartMonthIndex}">

                                </Picker>
                                <Label Text="&#x25BC;"
                                       VerticalOptions="Center" />
                            </HorizontalStackLayout>
                        </Frame>
                    </StackLayout>

                    <StackLayout>
                        <Frame CornerRadius="15"
                               BorderColor="Gray"
                               Padding="15,5,5,5"
                               WidthRequest="100"
                               HeightRequest="45">
                            <HorizontalStackLayout>
                                <Picker Title="Year"
                                        ItemsSource="{Binding StartYearPicker}"
                                        SelectedIndex="{Binding SelectedStartYearIndex}"
                                        HeightRequest="40">
                                </Picker>
                                <Label Text="&#x25BC;"
                                       VerticalOptions="Center" />
                            </HorizontalStackLayout>
                        </Frame>
                    </StackLayout>
                </HorizontalStackLayout>

                <Label Text="End Date"
                       Margin="0,20,0,0"
                       FontAttributes="Bold"
                       FontSize="Small" />

                <HorizontalStackLayout Margin="-5,0,0,10"
                                       Padding="5"
                                       Spacing="10">

                    <StackLayout>

                        <Frame CornerRadius="15"
                               BorderColor="Gray"
                               Padding="5"
                               WidthRequest="100"
                               HeightRequest="45">
                            <HorizontalStackLayout>
                                <Picker Title="Day"
                                        HeightRequest="40"
                                        ItemsSource="{Binding EndDayPicker}"
                                        SelectedIndex="{Binding SelectedEndDayIndex}"
                                        Margin="10,0,0,0">

                                </Picker>
                                <Label Text="&#x25BC;"
                                       VerticalOptions="Center" />
                            </HorizontalStackLayout>
                        </Frame>
                    </StackLayout>

                    <StackLayout>
                        <Frame CornerRadius="15"
                               BorderColor="Gray"
                               Padding="5"
                               WidthRequest="100"
                               HeightRequest="45">
                            <HorizontalStackLayout>
                                <Picker Title="Month"
                                        HeightRequest="40"
                                        ItemsSource="{Binding EndMonthPicker}"
                                        SelectedIndex="{Binding SelectedEndMonthIndex}"
                                        Margin="10,0,0,0">
                                </Picker>
                                <Label Text="&#x25BC;"
                                       VerticalOptions="Center" />
                            </HorizontalStackLayout>
                        </Frame>
                    </StackLayout>

                    <StackLayout Grid.Column="2"
                                 Grid.Row="1">
                        <Frame CornerRadius="15"
                               BorderColor="Gray"
                               Padding="15,5,5,5"
                               WidthRequest="100"
                               HeightRequest="45">
                            <HorizontalStackLayout>
                                <Picker Title="Year"
                                        ItemsSource="{Binding EndYearPicker}"
                                        SelectedIndex="{Binding SelectedEndYearIndex}"
                                        HeightRequest="40">

                                </Picker>
                                <Label Text="&#x25BC;"
                                       VerticalOptions="Center" />
                            </HorizontalStackLayout>
                        </Frame>
                    </StackLayout>
                </HorizontalStackLayout>
            </VerticalStackLayout>

            <VerticalStackLayout Grid.Row="2"
                                 VerticalOptions="End"
                                 Margin="0,0,0,0">
                <Button Text="Apply Filter"
                        Style="{StaticResource ButtonText}"
                       Clicked='Button_OnClicked' />

            </VerticalStackLayout>
        </Grid>
    </Frame>
</Grid>

</the49:BottomSheet>
public partial class FilterBottomSheet
{
private readonly TransactionFilterViewModel _viewModel;
public FilterBottomSheet(TransactionFilterViewModel viewModel)
{
_viewModel = viewModel;
InitializeComponent();
BindingContext = viewModel;

}

private async void Button_OnClicked(object? sender, EventArgs e)
{
   await _viewModel.ButtonClicked();
 
   await  BottomSheet.DismissAsync();
}


private void FilterBottomSheet_OnDismissed(object? sender, DismissOrigin e)
{
    var transactionView = (TransactionView)Shell.Current.CurrentPage;
    if (transactionView.BindingContext is TransactionViewModel viewModel)
    {
        viewModel.TransactionPageContentOpacity = 1.0;
    }
}

}

[QueryProperty(nameof(TransactionHistoryFilters),nameof(TransactionHistoryFilters))]
public partial class TransactionViewModel : ViewModelBase
{
[ObservableProperty]
private TransactionHistoryFilters _transactionHistoryFilters;

private  readonly IAlertService _alertService;
private readonly ITransactionService _transactionService;

private readonly IServiceProvider _serviceProvider;
public TransactionViewDataModel TransactionDataViewModel { get; set; } = new();

[ObservableProperty] private object _selectedItem;

[ObservableProperty] private bool _isBusy;

[ObservableProperty] private bool _isTransactionEnable;

private bool _isInitializing;

public TransactionViewModel(INavigator navigator,
    IAlertService alertService,
    ITransactionService transactionService, IServiceProvider serviceProvider) : base(navigator)
{
    _alertService = alertService;
    _transactionService = transactionService;
    _serviceProvider = serviceProvider;
    ToggleFilterCommand = new Command(o => ToggleFilter());

}

public ICommand ToggleFilterCommand { get; }
private double _transactionPageContentOpacity = 1.0;
public double TransactionPageContentOpacity
{
    get => _transactionPageContentOpacity;
    set
    {
        _transactionPageContentOpacity = value;
        OnPropertyChanged();
    }
}


public async Task InitAsync()
{
    if (_isInitializing)
        return;

    _isInitializing = true;
    try
    {
       
        IsBusy = true;
        IsTransactionEnable = false;

        TransactionDataViewModel.DashBoardResponse = await _transactionService.GetBalanceAsync();
        
        TransactionDataViewModel.TransactionListViewModels =
            await _transactionService.GetAllTransactionsTaskAsync(TransactionHistoryFilters);
        
       
        IsBusy = false;
        IsTransactionEnable = true;
      
    }
    catch (Exception ex)
    {
        await _alertService.ShowAlertAsync("ChangeBox EWallet",
            $"Error Navigating to Transaction Page {ex.Message}", "ok");
    }
    finally
    {
        _isInitializing = false;
    }
}

private async void ToggleFilter()
{
    TransactionPageContentOpacity = 0.5;
    var page = _serviceProvider.GetRequiredService<FilterBottomSheet>();
    page.HasHandle = true;
    page.HandleColor = Colors.Red;
    await page.ShowAsync();
  
    TransactionPageContentOpacity = 0.5;
}
here my handler not showing please help 
@vhugogarcia
Copy link

Hello @Shubhampandharpote23, could you please share a sample repository on GitHub showing your issue? 😃 so we can review it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants