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

[Bug]: Can't pushScreen with navBar before pushScreen without navbar #167

Open
v6nom opened this issue Jun 5, 2024 · 5 comments
Open

[Bug]: Can't pushScreen with navBar before pushScreen without navbar #167

v6nom opened this issue Jun 5, 2024 · 5 comments

Comments

@v6nom
Copy link

v6nom commented Jun 5, 2024

Version

5.2.3

Flutter Doctor Output

[✓] Flutter (Channel stable, 3.19.6, on macOS 14.5 23F79 darwin-arm64, locale fr-FR)
    • Flutter version 3.19.6 on channel stable at /Users/omid/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 54e66469a9 (7 weeks ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[✓] VS Code (version 1.89.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.90.0

[✓] Connected device (3 available)            
    • iPhone 15 Pro Max (mobile) • A5665398-B7F9-4C64-B557-03063DAD272F • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator)
    • macOS (desktop)            • macos                                • darwin-arm64   • macOS 14.5 23F79 darwin-arm64
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 125.0.6422.142

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.

What platforms are you seeing the problem on?

iOS

What happened?

Hello, i have a home page, when i click on a button this redirect me to a other page who named description, i use pushScreen whithout nav bar and this work. When im on the description page i need to redirect to other page but with nav bar

When i redirect the nav bar is not showed but it had to show.

Steps to reproduce

  1. Go to '.homepage'
  2. Click on 'description'
  3. Scroll down to '.
  4. See error

Code to reproduce the problem

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:provider/provider.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:persistent_bottom_nav_bar_v2/persistent_bottom_nav_bar_v2.dart';

import 'package:ayshglamm_app/model/prestations_model.dart';
import 'package:ayshglamm_app/screens/account/register_phone.dart';
import 'package:ayshglamm_app/screens/account/register_email.dart';
import 'package:ayshglamm_app/screens/account/login_email.dart';
import 'package:ayshglamm_app/screens/account/otp_phone.dart';
import 'package:ayshglamm_app/screens/account/splash_screen.dart';
import 'package:ayshglamm_app/screens/home/prestation_description.dart';
import 'package:ayshglamm_app/screens/home/home.dart';
import 'package:ayshglamm_app/screens/cart/cart.dart';
import 'package:ayshglamm_app/screens/cart/cart_empty.dart';
import 'package:ayshglamm_app/screens/cart/date_picker.dart';
import 'package:ayshglamm_app/screens/cart/artist_available.dart';
import 'package:ayshglamm_app/screens/home/home2.dart';
import 'package:ayshglamm_app/screens/account/provider/auth_provider.dart'
    as ap;
import 'firebase_options.dart';
import 'package:ayshglamm_app/globals/globals.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );
  flutterCart.initializeCart(isPersistenceSupportEnabled: true);

  // make navigation bar transparent
  SystemChrome.setSystemUIOverlayStyle(
    const SystemUiOverlayStyle(
      systemNavigationBarColor: Colors.transparent,
    ),
  );
  // make flutter draw behind navigation bar
  SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);

  runApp(const MainApp());
}

ValueNotifier<bool> showNavigationBar = ValueNotifier<bool>(true);
ValueNotifier<int> currentIndex = ValueNotifier<int>(0);

class MainApp extends StatelessWidget {
  const MainApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      designSize: const Size(390, 844),
      minTextAdapt: true,
      splitScreenMode: true,
      builder: (context, child) {
        return MultiProvider(
          providers: [
            ChangeNotifierProvider(create: (_) => ap.AuthProvider()),
          ],
          child: MaterialApp(
            theme: ThemeData(
              textSelectionTheme: const TextSelectionThemeData(
                cursorColor: Colors.black,
              ),
            ),
            home: const SplashScreen(),
            routes: {
              '/minimal': (context) => const MinimalExample(),
              '/register-phone': (context) => const RegisterPhonePage(),
              '/register-email': (context) =>
                  const RegisterPage(fromLogin: false),
              '/login': (context) => const LoginPage(),
              '/otp': (context) => const OTPPage(
                    verificationId: "",
                    phoneNumber: "",
                    fullName: "",
                  ),
              '/home2': (context) => const ChoicePrestation(),
              '/prestation-description': (context) => DescriptionPrestation(
                    prestation: Prestation(
                      id: "",
                      name: "",
                      description: "",
                      category: "",
                      price: 0,
                      active: true,
                      pictureLink: "",
                      totalSold: 0,
                      duration: 0,
                      completed: 0,
                      waiting: 0,
                      canceled: 0,
                      views: 0,
                      likes: 0,
                      specifications: '',
                      createdAt: DateTime.now().toString(),
                    ),
                  ),
              '/cart': (context) => const CartDetail(),
              '/cart-empty': (context) => const CartEmpty(),
              '/choice-meet': (context) => const ChoiceMeet(),
              '/available-artist': (context) =>
                  const ArtistAvailable(artists: []),
              '/home': (context) => const HomeView(),
            },
          ),
        );
      },
    );
  }
}

class MinimalExample extends StatelessWidget {
  const MinimalExample({super.key});

  List<PersistentTabConfig> _tabs() => [
        PersistentTabConfig(
          screen: const HomeView(),
          item: ItemConfig(
            icon: const Icon(Icons.home),
            title: "Home",
          ),
        ),
        PersistentTabConfig(
          screen: const CartDetail(),
          item: ItemConfig(
            icon: const Icon(Icons.shopping_cart),
            title: "Cart",
          ),
        ),
        PersistentTabConfig(
          screen: const ChoicePrestation(),
          item: ItemConfig(
            icon: const Icon(Icons.list),
            title: "Services",
          ),
        ),
      ];

  @override
  Widget build(BuildContext context) => PersistentTabView(
        tabs: _tabs(),
        navBarBuilder: (navBarConfig) => Style1BottomNavBar(
          navBarConfig: navBarConfig,
        ),
      );
}





onTap: () {
                                pushScreen(
                                  context,
                                  screen: DescriptionPrestation(
                                    prestation: prestation,
                                  ),
                                  withNavBar: false,
                                );
                              },//this work



 onPressed: () {
                                          addToCart(prestation);
                                          ScaffoldMessenger.of(context)
                                              .showSnackBar(
                                            SnackBar(
                                              content: Text(
                                                  'Prestation ajoutée au panier'),
                                              action: SnackBarAction(
                                                label: 'Voir le panier',
                                                onPressed: () {
                                                  pushScreen(
                                                    context,
                                                    screen: CartDetail(),
                                                    withNavBar: true,
                                                    pageTransitionAnimation:
                                                        PageTransitionAnimation
                                                            .cupertino,
                                                  );
                                                },
                                              ),
                                            ),
                                          );
                                        },//this dont work

Relevant log output

No response

Screenshots

No response

@jb3rndt
Copy link
Owner

jb3rndt commented Jun 9, 2024

Yeah that does not work, sorry. As soon as you push "without" the navbar, the pushed route will sit in the root navigator on top of everything else (including the navbar). Of course, other routes can be pushed on top of that, but in order to reveal the navbar (i.e. the "home" location of your app), all other routes have to be closed before.

@v6nom
Copy link
Author

v6nom commented Jun 9, 2024

how i can do that ? you can give me a code for example plz

@jb3rndt
Copy link
Owner

jb3rndt commented Jun 9, 2024 via email

@v6nom
Copy link
Author

v6nom commented Jun 9, 2024

this code for reshow the nav bar ?

@jb3rndt
Copy link
Owner

jb3rndt commented Jun 13, 2024

You can use this to pop all screens that cover the navbar (if there is no screen prior to PersistentTabView in the navigator history. Else, you need to adjust the condition in popUntil)

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