Skip to content

Commit 66b917c

Browse files
committed
first commit
0 parents  commit 66b917c

File tree

69 files changed

+4071
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+4071
-0
lines changed

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
26+
/pubspec.lock
27+
**/doc/api/
28+
.dart_tool/
29+
.packages
30+
build/

.metadata

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: "d211f42860350d914a5ad8102f9ec32764dc6d06"
8+
channel: "stable"
9+
10+
project_type: plugin
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06
17+
base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06
18+
- platform: windows
19+
create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06
20+
base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06
21+
22+
# User provided section
23+
24+
# List of Local paths (relative to this file) that should be
25+
# ignored by the migrate tool.
26+
#
27+
# Files that are not part of the templates will be ignored by default.
28+
unmanaged_files:
29+
- 'lib/main.dart'
30+
- 'ios/Runner.xcodeproj/project.pbxproj'

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 1.0.0
2+
3+
* Initial version

LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright 2023, jakky1 ([email protected])
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without modification,
7+
are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright
10+
notice, this list of conditions and the following disclaimer.
11+
* Redistributions in binary form must reproduce the above
12+
copyright notice, this list of conditions and the following
13+
disclaimer in the documentation and/or other materials provided
14+
with the distribution.
15+
* Neither the name of Google Inc. nor the names of its
16+
contributors may be used to endorse or promote products derived
17+
from this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
23+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
# jk_custom_appbar
2+
3+
Easy to use any custom widget as app bar / bottom bar. Support floating / pinned bars with scrolling behavior. Support in horizontal screen.
4+
5+
## Features
6+
7+
- Support bottom bar / app bar.
8+
- Use any custom widget as app bar / bottom bar.
9+
- Support reverse scrolling.
10+
- Support image background in app bar.
11+
- Support in horizontal mode.
12+
13+
# Quick Start
14+
15+
## Installation
16+
17+
Add this to your package's `pubspec.yaml` file:
18+
19+
```yaml
20+
dependencies:
21+
jk_custom_appbar: ^1.0.0
22+
```
23+
24+
# Usage
25+
26+
## Custom app bar / bottom bar
27+
28+
Both `appBar` and `bottomBar` can be expanded / collapsed during scrolling.
29+
30+
But `appBarPinned` and `bottomBarPinned` will not be expanded / collapsed during scrolling, and always shown on screen.
31+
32+
All these bars can be `null` (not shown) or put any your custom widget.
33+
34+
```
35+
var layout = JkAppBarLayout(
36+
appBar: Text("custom appBar widget here"), // optional
37+
appBarPinned: Text("custom appBarPinned widget here"), // optional
38+
bottomBar: Text("custom bottomBar widget here"), // optional
39+
bottomBarPinned: Text("custom bottomBarPinned widget here"), // optional
40+
);
41+
```
42+
43+
## Show ListView / GridView as content (Important !)
44+
45+
To show a ListView / GridView / SingleChildScrollView as content, we need to use `JkAppBarListView` / `JkAppBarGridView` / `JkAppBarSingleChildScrollView`.
46+
47+
The API of all the new three classes are all the same with flutter official classes, but only the class name changes.
48+
49+
NOTE: use flutter official ListView / GridView / SingleChildScrollView won't make app bars expand/collapse.
50+
51+
```
52+
var layout = JkAppBarLayout(
53+
...
54+
child: JkAppBarListView.builder( // API are the same with ListView
55+
itemCount: 300,
56+
itemBuilder: (context, index) => Text("List Item $index"),
57+
),
58+
);
59+
```
60+
61+
```
62+
var layout = JkAppBarLayout(
63+
...
64+
child: JkAppBarGridView.builder( // API are the same with GridView
65+
itemCount: 300,
66+
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
67+
crossAxisCount: 2, mainAxisExtent: 30),
68+
itemCount: 300,
69+
itemBuilder: (context, index) => Text("Grid Item $index"),
70+
),
71+
);
72+
```
73+
74+
```
75+
var layout = JkAppBarLayout(
76+
...
77+
child: JkAppBarSingleChildScrollView.builder( // API are the same with SingleChildScrollView
78+
child: Column(
79+
children: List.generate(100, (index) => Text("Column $index")),
80+
),
81+
),
82+
);
83+
```
84+
85+
## Snapping & Floating
86+
87+
`floating`=true means the `appBar` and `bottomBar` will be expanded anywhere when scrolling backward.
88+
89+
`floating`=false means the `appBar` and `bottomBar` ONLY be expanded anywhere when scrolling back to beginning of list.
90+
91+
`snap`=true means the `appBar` and `bottomBar` will be automatically expanded/collapseed when tapUp if bars not fully expanded/collapsed.
92+
93+
```
94+
var layout = JkAppBarLayout(
95+
...
96+
floating: true,
97+
snap: true,
98+
);
99+
```
100+
101+
## Image background
102+
103+
Return an Image widget in `appBarBackgroundBuilder` to show an image as background of `appBar`.
104+
105+
`appBarBackgroundBuilder` is called every time when collapsed size changed, so typically we can make a fading effect for the image background here.
106+
107+
Set `backgroundIncludingAppBarPinned` as `true` makes the image also covers the area of `appBarPinned`.
108+
109+
```
110+
var layout = JkAppBarLayout(
111+
...
112+
backgroundIncludingAppBarPinned: true,
113+
appBarBackgroundBuilder: (collapsedRatio) {
114+
return Opacity(
115+
opacity: 1 - collapsedRatio,
116+
child: Image.asset("assets/your_background.jpg",
117+
fit: BoxFit.cover));
118+
},
119+
);
120+
```
121+
122+
## Colored background
123+
124+
By default, we apply the color of system default AppBar as background.
125+
126+
You can customize the color by `appBarBackgroundColor`:
127+
128+
```
129+
var layout = JkAppBarLayout(
130+
...
131+
appBarBackgroundColor: Colors.green,
132+
);
133+
```
134+
135+
## Default text size/color and icon color
136+
137+
By default, all the text size/color and icon color on the `appBar`, `appBarPinned`, `bottomBar`, `bottomBarPinned` will be the same with default system AppBar.
138+
139+
If you want to ignore these default theme/style, set `appBarDefaultTheme` as false:
140+
141+
```
142+
var layout = JkAppBarLayout(
143+
...
144+
appBarDefaultTheme: false,
145+
);
146+
```
147+
148+
## Horizontal support
149+
150+
Set `scrollDirection` as `Axis.horizontal` to show app bars in horizontal mode.
151+
152+
Don't forget to set the `scrollDirection` in `JkAppBarListView` / `JkAppBarGridView` / `JkAppBarSingleChildScrollView` at the same time.
153+
154+
```
155+
var layout = JkAppBarLayout(
156+
...
157+
scrollDirection: Axis.horizontal,
158+
159+
child: JkAppBarListView.builder(
160+
scrollDirection: Axis.horizontal, // Don't forget this
161+
itemCount: 300,
162+
itemBuilder: (context, index) => Text("List Item $index"),
163+
),
164+
);
165+
```
166+
167+
## Sample code
168+
169+
```
170+
import 'package:flutter/material.dart';
171+
import 'package:jk_custom_appbar/jk_appbar.dart';
172+
173+
void main() {
174+
runApp(const MyApp());
175+
}
176+
177+
class MyApp extends StatefulWidget {
178+
const MyApp({super.key});
179+
180+
@override
181+
State<MyApp> createState() => _MyAppState();
182+
}
183+
184+
class _MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
185+
@override
186+
Widget build(BuildContext context) {
187+
Widget child = JkAppBarLayout(
188+
appBar: Text("appBar"), // optional
189+
appBarPinned: Text("appBarPinned"), // optional
190+
bottomBarPinned: Text("bottomBarPinned"), // optional
191+
bottomBar: Text("bottomBar"), // optional
192+
child: JkAppBarListView.builder(
193+
itemCount: 300,
194+
itemBuilder: (_, index) => Text("Item $index"),
195+
)
196+
);
197+
198+
return MaterialApp(
199+
home: Scaffold(
200+
body: child,
201+
),
202+
);
203+
}
204+
}
205+
```

analysis_options.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include: package:flutter_lints/flutter.yaml
2+
3+
# Additional information about this file can be found at
4+
# https://dart.dev/guides/language/analysis-options

example/.gitignore

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
**/doc/api/
26+
**/ios/Flutter/.last_build_id
27+
.dart_tool/
28+
.flutter-plugins
29+
.flutter-plugins-dependencies
30+
.packages
31+
.pub-cache/
32+
.pub/
33+
/build/
34+
35+
# Symbolication related
36+
app.*.symbols
37+
38+
# Obfuscation related
39+
app.*.map.json
40+
41+
# Android Studio will place build artifacts here
42+
/android/app/debug
43+
/android/app/profile
44+
/android/app/release

example/.metadata

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: "db7ef5bf9f59442b0e200a90587e8fa5e0c6336a"
8+
channel: "stable"
9+
10+
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
17+
base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
18+
- platform: android
19+
create_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
20+
base_revision: db7ef5bf9f59442b0e200a90587e8fa5e0c6336a
21+
22+
# User provided section
23+
24+
# List of Local paths (relative to this file) that should be
25+
# ignored by the migrate tool.
26+
#
27+
# Files that are not part of the templates will be ignored by default.
28+
unmanaged_files:
29+
- 'lib/main.dart'
30+
- 'ios/Runner.xcodeproj/project.pbxproj'

example/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# jk_custom_appbar_example
2+
3+
Demonstrates how to use the jk_custom_appbar plugin.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter application.
8+
9+
A few resources to get you started if this is your first Flutter project:
10+
11+
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12+
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
13+
14+
For help getting started with Flutter development, view the
15+
[online documentation](https://docs.flutter.dev/), which offers tutorials,
16+
samples, guidance on mobile development, and a full API reference.

0 commit comments

Comments
 (0)