Skip to content

Commit 0beab81

Browse files
committed
v3.0.0
code refactor readme updated
1 parent e3f6241 commit 0beab81

25 files changed

+923
-770
lines changed

README.md

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies:
2525
# Features
2626
2727
- Slider with custom animation time
28-
- Provide Basic Appbar with customization of color, size and title
28+
- Provide Basic Appbar with customization of color and title
2929
- Dynamic slider open and close offset
3030
- Provide drawer icon animation
3131
- Provide shadow of Main screen with customization of shadow colors,blurRadius and spreadRadius
@@ -37,32 +37,34 @@ dependencies:
3737
# Code
3838

3939
```
40-
Widget build(BuildContext context) {
41-
return Scaffold(
42-
body: SliderDrawer(
43-
key: _key,
44-
appBar: SliderAppBar(
45-
appBarColor: Colors.white,
46-
title: Text(title,
47-
style: const TextStyle(
48-
fontSize: 22, fontWeight: FontWeight.w700))),
49-
slider: Container(color: Colors.red),
50-
child: Container(color: Colors.amber),
51-
));
52-
}
40+
Widget build(BuildContext context) {
41+
return Scaffold(
42+
body: SliderDrawer(
43+
key: _sliderDrawerKey,
44+
appBar: SliderAppBar(
45+
config: SliderAppBarConfig(
46+
title: Text(
47+
title,
48+
textAlign: TextAlign.center,
49+
style: const TextStyle(
50+
fontSize: 22,
51+
fontWeight: FontWeight.w700,
52+
),
53+
)),
54+
),
55+
sliderOpenSize: 179,
56+
slider: Container(color: Colors.red),
57+
child: Container(color: Colors.amber),
58+
));
59+
}
5360
```
5461
5562
</br>
5663
</br>
5764
58-
![slider_document](slider_d_1.png)
59-
</br>
65+
![slider_document](information.png)
6066
</br>
6167
</br>
62-
</br>
63-
64-
![slider_document](slider_d_2.png)
65-
6668
</br>
6769
</br>
6870
@@ -81,18 +83,26 @@ dependencies:
8183
8284
```
8385
class _MyAppState extends State<MyApp> {
84-
GlobalKey<SliderDrawerState> _key = GlobalKey<SliderDrawerState>();
86+
GlobalKey<SliderDrawerState> _sliderDrawerKey = GlobalKey<SliderDrawerState>();
8587

8688
@override
8789
Widget build(BuildContext context) {
8890
return Scaffold(
8991
body: SliderDrawer(
90-
key: _key,
92+
key: _sliderDrawerKey,
9193
appBar: SliderAppBar(
92-
appBarColor: Colors.white,
93-
title: Text('Title',
94-
style:
95-
const TextStyle(fontSize: 22, fontWeight: FontWeight.w700))),
94+
config: SliderAppBarConfig(
95+
title: Text(
96+
title,
97+
textAlign: TextAlign.center,
98+
style: const TextStyle(
99+
fontSize: 22,
100+
fontWeight: FontWeight.w700,
101+
),
102+
),
103+
),
104+
),
105+
sliderOpenSize: 179,
96106
slider: Container(color: Colors.red),
97107
child: Container(color: Colors.amber),
98108
));
@@ -103,16 +113,16 @@ class _MyAppState extends State<MyApp> {
103113
104114
* Using the below methods to control drawer .
105115
```
106-
_key.currentState.closeDrawer();
107-
_key.currentState.openDrawer();
108-
_key.currentState.toggle();
109-
_key.currentState.isDrawerOpen();
116+
_sliderDrawerKey.currentState.closeDrawer();
117+
_sliderDrawerKey.currentState.openDrawer();
118+
_sliderDrawerKey.currentState.toggle();
119+
_sliderDrawerKey.currentState.isDrawerOpen();
110120

111121
```
112122
* Use below variable if you want to control animation.
113123
114124
115-
``` _key.currentState.animationController```
125+
``` __sliderDrawerKey.currentState.animationController```
116126
117127
# Contribute to Development
118128
Your contribution will help improve the plugin

example/ios/Runner/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import UIKit
22
import Flutter
33

4-
@UIApplicationMain
4+
@main
55
@objc class AppDelegate: FlutterAppDelegate {
66
override func application(
77
_ application: UIApplication,

example/lib/home/home_page.dart

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import 'package:example/home/widget/author_list.dart';
2+
import 'package:example/home/widget/slider_menu.dart';
3+
import 'package:flutter/widgets.dart';
4+
import 'package:flutter_slider_drawer/flutter_slider_drawer.dart';
5+
6+
class HomePage extends StatefulWidget {
7+
const HomePage({super.key});
8+
9+
@override
10+
State<HomePage> createState() => _HomePageState();
11+
}
12+
13+
class _HomePageState extends State<HomePage> {
14+
final GlobalKey<SliderDrawerState> _sliderDrawerKey =
15+
GlobalKey<SliderDrawerState>();
16+
17+
late String title;
18+
19+
@override
20+
void initState() {
21+
title = "Home";
22+
super.initState();
23+
}
24+
25+
@override
26+
Widget build(BuildContext context) {
27+
return SafeArea(
28+
child: SliderDrawer(
29+
key: _sliderDrawerKey,
30+
appBar: SliderAppBar(
31+
config: SliderAppBarConfig(
32+
title: Text(
33+
title,
34+
textAlign: TextAlign.center,
35+
style: const TextStyle(
36+
fontSize: 22,
37+
fontWeight: FontWeight.w700,
38+
),
39+
)),
40+
),
41+
sliderOpenSize: 179,
42+
slider: SliderMenu(
43+
onItemClick: (title) {
44+
_sliderDrawerKey.currentState?.closeSlider();
45+
setState(() {
46+
this.title = title;
47+
});
48+
},
49+
),
50+
child: const AuthorList(),
51+
),
52+
);
53+
}
54+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import 'package:example/model/quotes.dart';
2+
import 'package:flutter/material.dart';
3+
4+
class AuthorList extends StatelessWidget {
5+
const AuthorList({super.key});
6+
7+
@override
8+
Widget build(BuildContext context) {
9+
List<Quotes> quotesList = [];
10+
quotesList.add(Quotes(
11+
Colors.amber,
12+
'Amelia Brown',
13+
'Life would be a great deal easier if dead things had the decency to remain dead.',
14+
));
15+
quotesList.add(Quotes(
16+
Colors.orange,
17+
'Olivia Smith',
18+
'That proves you are unusual," returned the Scarecrow',
19+
));
20+
quotesList.add(Quotes(
21+
Colors.deepOrange,
22+
'Sophia Jones',
23+
'Her name badge read: Hello! My name is DIE, DEMIGOD SCUM!',
24+
));
25+
quotesList.add(Quotes(
26+
Colors.red,
27+
'Isabella Johnson',
28+
'I am about as intimidating as a butterfly.',
29+
));
30+
quotesList.add(Quotes(
31+
Colors.purple,
32+
'Emily Taylor',
33+
'Never ask an elf for help; they might decide your better off dead, eh?',
34+
));
35+
quotesList.add(Quotes(
36+
Colors.green,
37+
'Maya Thomas',
38+
'Act first, explain later',
39+
));
40+
41+
return Container(
42+
padding: const EdgeInsets.symmetric(horizontal: 12),
43+
child: ListView.separated(
44+
scrollDirection: Axis.vertical,
45+
padding: const EdgeInsets.all(12),
46+
itemBuilder: (builder, index) {
47+
return Container(
48+
decoration: BoxDecoration(
49+
color: quotesList[index].color,
50+
borderRadius: const BorderRadius.all(
51+
Radius.circular(10.0),
52+
),
53+
),
54+
child: Padding(
55+
padding: const EdgeInsets.all(8.0),
56+
child: Column(
57+
mainAxisSize: MainAxisSize.min,
58+
crossAxisAlignment: CrossAxisAlignment.start,
59+
children: <Widget>[
60+
Text(
61+
quotesList[index].quote,
62+
style: const TextStyle(
63+
fontSize: 20,
64+
color: Colors.white,
65+
),
66+
),
67+
Align(
68+
alignment: Alignment.centerRight,
69+
child: Text(
70+
'-${quotesList[index].author}',
71+
textAlign: TextAlign.right,
72+
style: const TextStyle(
73+
fontSize: 12,
74+
color: Colors.white,
75+
),
76+
),
77+
),
78+
],
79+
),
80+
),
81+
);
82+
},
83+
separatorBuilder: (builder, index) {
84+
return const Divider(
85+
height: 10,
86+
thickness: 0,
87+
);
88+
},
89+
itemCount: quotesList.length),
90+
);
91+
}
92+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import 'package:example/model/menu.dart';
2+
import 'package:flutter/material.dart';
3+
4+
class SliderMenu extends StatelessWidget {
5+
final Function(String)? onItemClick;
6+
7+
const SliderMenu({Key? key, this.onItemClick}) : super(key: key);
8+
9+
@override
10+
Widget build(BuildContext context) {
11+
return Container(
12+
color: Colors.white,
13+
padding: const EdgeInsets.only(top: 30),
14+
child: ListView(
15+
children: <Widget>[
16+
const SizedBox(height: 30),
17+
const _Profile(),
18+
const SizedBox(height: 20),
19+
...[
20+
Menu(Icons.home, 'Home'),
21+
Menu(Icons.add_circle, 'Add Post'),
22+
Menu(Icons.notifications_active, 'Notification'),
23+
Menu(Icons.favorite, 'Likes'),
24+
Menu(Icons.settings, 'Setting'),
25+
Menu(Icons.arrow_back_ios, 'LogOut')
26+
]
27+
.map((menu) => _MenuItem(
28+
title: menu.title,
29+
iconData: menu.iconData,
30+
onTap: onItemClick))
31+
.toList(),
32+
],
33+
),
34+
);
35+
}
36+
}
37+
38+
class _MenuItem extends StatelessWidget {
39+
final String title;
40+
final IconData iconData;
41+
final Function(String)? onTap;
42+
43+
const _MenuItem(
44+
{Key? key,
45+
required this.title,
46+
required this.iconData,
47+
required this.onTap})
48+
: super(key: key);
49+
50+
@override
51+
Widget build(BuildContext context) {
52+
return ListTile(
53+
title: Text(title, style: const TextStyle(color: Colors.black)),
54+
leading: Icon(iconData, color: Colors.black),
55+
onTap: () => onTap?.call(title));
56+
}
57+
}
58+
59+
class _Profile extends StatelessWidget {
60+
const _Profile();
61+
62+
@override
63+
Widget build(BuildContext context) {
64+
return Column(
65+
mainAxisSize: MainAxisSize.min,
66+
children: [
67+
CircleAvatar(
68+
radius: 62,
69+
backgroundColor: Colors.black26,
70+
child: CircleAvatar(
71+
radius: 60,
72+
backgroundImage: Image.network(
73+
'https://nikhilvadoliya.github.io/assets/images/nikhil_1.webp')
74+
.image,
75+
),
76+
),
77+
const SizedBox(height: 20),
78+
const Text(
79+
'Nikhil',
80+
textAlign: TextAlign.center,
81+
style: TextStyle(
82+
color: Colors.black,
83+
fontWeight: FontWeight.bold,
84+
fontSize: 30,
85+
),
86+
),
87+
],
88+
);
89+
}
90+
}

0 commit comments

Comments
 (0)