diff --git a/.github/workflows/flutter.yml b/.github/workflows/flutter.yml new file mode 100644 index 0000000..367279c --- /dev/null +++ b/.github/workflows/flutter.yml @@ -0,0 +1,42 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Flutter action + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + # Note: This workflow uses the latest stable version of the Dart SDK. + # You can specify other versions if desired, see documentation here: + # https://github.com/dart-lang/setup-dart/blob/main/README.md + - uses: dart-lang/setup-dart@v1.3 + + - uses: subosito/flutter-action@v2.8.0 + + - name: Install dependencies + run: flutter pub get + + - name: Verify formatting + run: flutter format --output=none --set-exit-if-changed . + + # Consider passing '--fatal-infos' for slightly stricter analysis. + - name: Analyze project source + run: flutter analyze + + # Your project will need to have tests in test/ and a dependency on + # package:test for this step to succeed. Note that Flutter projects will + # want to change this to 'flutter test'. + # - name: Run tests + # run: flutter test diff --git a/CHANGELOG.md b/CHANGELOG.md index b4e0086..be59d57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## [2.0.3] +- Integrate original changes + +## [2.0.2] +- update README and format code + +## [2.0.1] +- add dart doc + +## [2.0.0] +- add label + ## [1.0.6] - set minimum flutter sdk version to 3.10.0 to support MediaQuery.sizeOf diff --git a/LICENSE b/LICENSE index 43c43cf..4b07edc 100644 --- a/LICENSE +++ b/LICENSE @@ -1,9 +1,20 @@ -Copyright 2019 RafaƂ Bednarczuk rafbednarczuk@gmail.com +Copyright 2022 Nam Anh Nguyen namanh11611@gmail.com -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +Redistribution and use in source and binary forms, with or without modification, are permitted +provided that the following conditions are met: -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +1. Redistributions of source code must retain the above copyright notice, this list of conditions +and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions +and the following disclaimer in the documentation and/or other materials provided with the +distribution. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF +THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/README.md b/README.md index 9bb097b..8a41448 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,18 @@ -# curved_navigation_bar -[pub package](https://pub.dartlang.org/packages/curved_navigation_bar) +# curved_labeled_navigation_bar +[pub package](https://pub.dartlang.org/packages/curved_labeled_navigation_bar) -A Flutter package for easy implementation of curved navigation bar. +A Flutter package for easy implementation of curved navigation bar. +This package is a fork of the original curved_navigation_bar from https://github.com/rafalbednarczuk/curved_navigation_bar with label for CurvedNavigationBarItem. -![Gif](https://github.com/rafalbednarczuk/curved_navigation_bar/blob/master/example.gif "Fancy Gif") +| Label | No Label | +|--------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------| +| ![Gif](https://github.com/namanh11611/curved_labeled_navigation_bar/blob/master/label.gif "Label Gif") | ![Gif](https://github.com/namanh11611/curved_labeled_navigation_bar/blob/master/no_label.gif "No Label Gif") | ### Add dependency ```yaml dependencies: - curved_navigation_bar: ^1.0.6 #latest version + curved_labeled_navigation_bar: ^2.0.3 #latest version ``` ### Easy to use @@ -18,13 +21,30 @@ dependencies: Scaffold( bottomNavigationBar: CurvedNavigationBar( backgroundColor: Colors.blueAccent, - items: [ - Icon(Icons.add, size: 30), - Icon(Icons.list, size: 30), - Icon(Icons.compare_arrows, size: 30), + items: [ + CurvedNavigationBarItem( + child: Icon(Icons.home_outlined), + label: 'Home', + ), + CurvedNavigationBarItem( + child: Icon(Icons.search), + label: 'Search', + ), + CurvedNavigationBarItem( + child: Icon(Icons.chat_bubble_outline), + label: 'Chat', + ), + CurvedNavigationBarItem( + child: Icon(Icons.newspaper), + label: 'Feed', + ), + CurvedNavigationBarItem( + child: Icon(Icons.perm_identity), + label: 'Personal', + ), ], onTap: (index) { - //Handle button tap + // Handle button tap }, ), body: Container(color: Colors.blueAccent), @@ -33,23 +53,35 @@ Scaffold( ### Attributes -`items`: List of Widgets\ -`index`: index of NavigationBar, can be used to change current index or to set initial index\ -`color`: Color of NavigationBar, default Colors.white\ -`buttonBackgroundColor`: background color of floating button, default same as color attribute\ -`backgroundColor`: Color of NavigationBar's background, default Colors.blueAccent\ -`onTap`: Function handling taps on items\ -`animationCurve`: Curves interpolating button change animation, default Curves.easeOutCubic\ -`animationDuration`: Duration of button change animation, default Duration(milliseconds: 600)\ -`height`: Height of NavigationBar, min 0.0, max 75.0\ -`maxWidth`: Allows to set the width of the navigation bar lower than the entire screen width by default\ -`letIndexChange`: Function which takes page index as argument and returns bool. If function returns false then page is not changed on button tap. It returns true by default\ +#### CurvedNavigationBar +| Attribute | Description | +|-------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `items` | List of CurvedNavigationBarItem | +| `index` | Index of NavigationBar, can be used to change current index or to set initial index | +| `color` | Color of NavigationBar, default Colors.white | +| `buttonBackgroundColor` | Background color of floating button, default same as color attribute | +| `backgroundColor` | Color of NavigationBar's background, default Colors.blueAccent | +| `onTap` | Function handling taps on items | +| `letIndexChange` | Function which takes page index as argument and returns bool. If function returns false then page is not changed on button tap. It returns true by default | +| `animationCurve` | Curves interpolating button change animation, default Curves.easeOut | +| `animationDuration` | Duration of button change animation, default Duration(milliseconds: 600) | +| `height` | Height of NavigationBar | +| `maxWidth` | Allows to set the width of the navigation bar lower than the entire screen width by default | +| `iconPadding` | Padding of icon in floating button | + +#### CurvedNavigationBarItem + +| Attribute | Description | +|--------------|---------------------------------| +| `child` | Icon of CurvedNavigationBarItem | +| `label` | Text of CurvedNavigationBarItem | +| `labelStyle` | TextStyle for label | ### Change page programmatically ```dart - //State class + // State class int _page = 0; GlobalKey _bottomNavigationKey = GlobalKey(); @@ -58,10 +90,27 @@ Scaffold( return Scaffold( bottomNavigationBar: CurvedNavigationBar( key: _bottomNavigationKey, - items: [ - Icon(Icons.add, size: 30), - Icon(Icons.list, size: 30), - Icon(Icons.compare_arrows, size: 30), + items: [ + CurvedNavigationBarItem( + child: Icon(Icons.home_outlined), + label: 'Home', + ), + CurvedNavigationBarItem( + child: Icon(Icons.search), + label: 'Search', + ), + CurvedNavigationBarItem( + child: Icon(Icons.chat_bubble_outline), + label: 'Chat', + ), + CurvedNavigationBarItem( + child: Icon(Icons.newspaper), + label: 'Feed', + ), + CurvedNavigationBarItem( + child: Icon(Icons.perm_identity), + label: 'Personal', + ), ], onTap: (index) { setState(() { @@ -78,7 +127,7 @@ Scaffold( ElevatedButton( child: Text('Go To Page of index 1'), onPressed: () { - //Page change using state does the same as clicking index 1 navigation button + // Page change using state does the same as clicking index 1 navigation button final CurvedNavigationBarState? navBarState = _bottomNavigationKey.currentState; navBarState?.setPage(1); @@ -87,6 +136,7 @@ Scaffold( ], ), ), - )); + ), + ); } ``` \ No newline at end of file diff --git a/example.gif b/example.gif deleted file mode 100644 index b5b5f88..0000000 Binary files a/example.gif and /dev/null differ diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 9991c9e..3d26a14 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,36 +1,35 @@ - + + + android:name="io.flutter.embedding.android.NormalTheme" + android:resource="@style/NormalTheme" /> + android:name="io.flutter.embedding.android.SplashScreenDrawable" + android:resource="@drawable/launch_background" /> - - + +