Skip to content

Commit

Permalink
Implement label
Browse files Browse the repository at this point in the history
  • Loading branch information
namanh11611 committed Nov 9, 2024
1 parent bd53cc4 commit 5ec8624
Show file tree
Hide file tree
Showing 17 changed files with 423 additions and 182 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/flutter.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- uses: subosito/[email protected]

- 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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
21 changes: 16 additions & 5 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
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.
106 changes: 78 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,13 +21,30 @@ dependencies:
Scaffold(
bottomNavigationBar: CurvedNavigationBar(
backgroundColor: Colors.blueAccent,
items: <Widget>[
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),
Expand All @@ -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<CurvedNavigationBarState> _bottomNavigationKey = GlobalKey();
Expand All @@ -58,10 +90,27 @@ Scaffold(
return Scaffold(
bottomNavigationBar: CurvedNavigationBar(
key: _bottomNavigationKey,
items: <Widget>[
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(() {
Expand All @@ -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);
Expand All @@ -87,6 +136,7 @@ Scaffold(
],
),
),
));
),
);
}
```
Binary file removed example.gif
Binary file not shown.
25 changes: 12 additions & 13 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.example">
<application
android:label="example"
android:icon="@mipmap/ic_launcher">

<application
android:icon="@mipmap/ic_launcher"
android:label="example">
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
Expand Down
Loading

0 comments on commit 5ec8624

Please sign in to comment.