Mindinventory / animated_notch_bottom_bar

Tabbar component for Flutter
MIT License
115 stars 33 forks source link

Layout goes up too far when keypad showing #19

Closed erjiridholubis closed 11 months ago

erjiridholubis commented 11 months ago

Hi, please fix this issue.

I am trying to create a form input and add a navbar. However, when the keypad is displayed, the layout goes up too far.

With Navbar :

https://github.com/Mindinventory/animated_notch_bottom_bar/assets/67106888/e87605b7-1441-41e5-9362-f7ba14ed3339

Without Navbar :

https://github.com/Mindinventory/animated_notch_bottom_bar/assets/67106888/9a466b2f-60a0-412b-94a7-68132c5e63c6

The Code form input :

  @override
  Widget build(BuildContext context) {
    double screenWidth = MediaQuery.of(context).size.width;

    return Scaffold(
      body: Column(
          children: [
            Container(
              width: screenWidth,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(25.0),
                color: const Color(0xfffba1b7),
              ),
              child: Column(
                children: [
                  const SizedBox(height: 60.0),
                  Row(
                    children: [
                      const SizedBox(width: 40.0),
                      const Expanded(
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            SizedBox(height: 30.0),
                            Text(
                              'INPUT,',
                              style: TextStyle(
                                fontSize: 16.0,
                                fontWeight: FontWeight.w600,
                              ),
                            ),
                            SizedBox(height: 8.0),
                            Text(
                              'REKAM MEDIS',
                              style: TextStyle(
                                fontSize: 20.0,
                                fontWeight: FontWeight.w300,
                              ),
                            ),
                            SizedBox(height: 8.0),
                          ],
                        ),
                      ),
                      Image.asset(
                        "assets/illustrations/input.png",
                        width: 120,
                        height: 120,
                      ),
                      const SizedBox(width: 40.0),
                    ],
                  ),

                  const SizedBox(height: 20.0),
                ],
              ),
            ),

            const SizedBox(height: 40.0),

            Padding(
              padding: const EdgeInsets.only(left: 20.0, right: 20.0),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [

                  TextField(
                    decoration: InputDecoration(
                      labelText: 'Nomor Rekam Medis',
                      border: OutlineInputBorder(
                        borderRadius: BorderRadius.circular(5.0),
                      ),
                      fillColor: Colors.white,
                      filled: true,
                    ),
                    style: const TextStyle(

                    ),
                  ),

                  const SizedBox(height: 20.0),
                ],
              ),
            ),

          ],
        ),
    );
  }
mi-raj04 commented 11 months ago
@erjiridholubis please try this to solve your issue 
Scaffold(
  resizeToAvoidBottomInset: false,
  // other properties and widgets for your scaffold
  appBar: AppBar(
    title: Text('Your App'),
  ),
  body: YourBodyWidget(),
  // ... other properties
);

This will prevent the body from resizing to avoid the bottom inset when the keyboard is displayed. Make sure to replace YourBodyWidget() with the actual widget you want to use as the body of your scaffold. If you have any specific questions or if there's anything else you'd like assistance with, feel free to provide more details!

erjiridholubis commented 11 months ago

still not working

1developersanju commented 11 months ago

yeah it's not working for me too, it would be helpful if i get a solution for this.

mi-raj04 commented 11 months ago

https://github.com/Mindinventory/animated_notch_bottom_bar/assets/135205978/d75b95c3-435d-4699-9ca6-f92347b06378

@erjiridholubis, below is an example I created using your code, and it's working fine. Please check and compare your code with that. If you're still facing any issues, please provide me your code with bottom bar implementation and specify the Dart version.

import 'dart:developer';

import 'package:animated_notch_bottom_bar/animated_notch_bottom_bar/animated_notch_bottom_bar.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const BottomBar(),
    );
  }
}

class BottomBar extends StatefulWidget {
  const BottomBar({super.key});

  @override
  State<BottomBar> createState() => _BottomBarState();
}

class _BottomBarState extends State<BottomBar> {
  final _pageController = PageController(initialPage: 0);
  final _controller = NotchBottomBarController(index: 0);
  int maxCount = 5;

  final List<Widget> bottomBarPages = [
    const FirstScreen(),
    Container(
      color: Colors.redAccent,
    ),
    Container(
      color: Colors.greenAccent,
    ),
    Container(
      color: Colors.blueAccent,
    ),
  ];

  @override
  void dispose() {
    _pageController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      body: PageView(
        controller: _pageController,
        physics: const NeverScrollableScrollPhysics(),
        children: List.generate(bottomBarPages.length, (index) => bottomBarPages[index]),
      ),
      extendBody: true,
      bottomNavigationBar: (bottomBarPages.length <= maxCount)
          ? AnimatedNotchBottomBar(
              /// Provide NotchBottomBarController
              notchBottomBarController: _controller,
              color: Colors.white,
              showLabel: false,
              notchColor: Colors.black87,

              /// restart app if you change removeMargins
              removeMargins: false,
              bottomBarWidth: 500,
              durationInMilliSeconds: 300,
              bottomBarItems: const [
                BottomBarItem(
                  inActiveItem: Icon(
                    Icons.home_filled,
                    color: Colors.blueGrey,
                  ),
                  activeItem: Icon(
                    Icons.home_filled,
                    color: Colors.blueAccent,
                  ),
                  itemLabel: 'Page 1',
                ),
                BottomBarItem(
                  inActiveItem: Icon(
                    Icons.star,
                    color: Colors.blueGrey,
                  ),
                  activeItem: Icon(
                    Icons.star,
                    color: Colors.blueAccent,
                  ),
                  itemLabel: 'Page 2',
                ),
                BottomBarItem(
                  inActiveItem: Icon(
                    Icons.settings,
                    color: Colors.blueGrey,
                  ),
                  activeItem: Icon(
                    Icons.settings,
                    color: Colors.pink,
                  ),
                  itemLabel: 'Page 3',
                ),
              ],
              onTap: (index) {
                /// perform action on tab change and to update pages you can update pages without pages
                log('current selected index $index');
                _pageController.jumpToPage(index);
              },
            )
          : null,
    );
  }
}

class FirstScreen extends StatefulWidget {
  const FirstScreen({super.key});

  @override
  State<FirstScreen> createState() => _FirstScreenState();
}

class _FirstScreenState extends State<FirstScreen> {
  @override
  Widget build(BuildContext context) {
    double screenWidth = MediaQuery.of(context).size.width;

    return Scaffold(
      body: Column(
        children: [
          Container(
            width: screenWidth,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(25.0),
              color: const Color(0xfffba1b7),
            ),
            child: Column(
              children: [
                const SizedBox(height: 60.0),
                Row(
                  children: [
                    const SizedBox(width: 40.0),
                    const Expanded(
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          SizedBox(height: 30.0),
                          Text(
                            'INPUT,',
                            style: TextStyle(
                              fontSize: 16.0,
                              fontWeight: FontWeight.w600,
                            ),
                          ),
                          SizedBox(height: 8.0),
                          Text(
                            'REKAM MEDIS',
                            style: TextStyle(
                              fontSize: 20.0,
                              fontWeight: FontWeight.w300,
                            ),
                          ),
                          SizedBox(height: 8.0),
                        ],
                      ),
                    ),
                    Container(
                      color: Colors.redAccent,
                      width: 120,
                      height: 120,
                    ),
                    const SizedBox(width: 40.0),
                  ],
                ),
                const SizedBox(height: 20.0),
              ],
            ),
          ),
          const SizedBox(height: 40.0),
          Padding(
            padding: const EdgeInsets.only(left: 20.0, right: 20.0),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                TextField(
                  decoration: InputDecoration(
                    labelText: 'Nomor Rekam Medis',
                    border: OutlineInputBorder(
                      borderRadius: BorderRadius.circular(5.0),
                    ),
                    fillColor: Colors.white,
                    filled: true,
                  ),
                  style: const TextStyle(),
                ),
                const SizedBox(height: 20.0),
              ],
            ),
          ),
        ],
      ),
    );
  }
}