Skip to content

Commit

Permalink
add Controller and update example.
Browse files Browse the repository at this point in the history
  • Loading branch information
mahmoud-haj-ali committed Jul 5, 2021
1 parent 32eff92 commit 8897d9e
Show file tree
Hide file tree
Showing 9 changed files with 353 additions and 323 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.1.0] - July 2021

* Add Controller and update example.

## [1.0.2] - July 2021

* Add images.
Expand Down
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,36 @@ A Flutter side bar slider can be with any widget you want
* Customizable `clicker`, you can change the clicker widget with what you want.
* Just like Flutter's `Drawer`, but with new way.

## Things to note

* The `SlidableBar` should have specific width and height, it works fine with scaffold's body.
* The `SlidableBar` doesn't create it's own context, so it will appear under floating action button if you add one.

## Usage

```dart
final SlidableBarController controller = SlidableBarController(initialStatus: true);
SlidableBar(
width: 50, // this will be the height when you change the side to bottom or top
frontColor: Colors.green, // the color of the cycle inside the default clicker
size: 50, // this will be bar's height in case Side is bottom or top and width in case Side is left or right
children: <Widget>[], // here is the widgets inside the bar
child: Container(), // here is your page body
child: Container(), // here is your widget that will be under the bar
// optional
frontColor: Colors.green, // the color of the cycle inside the default clicker
slidableController: controller, // the contoller to change and listen to the bar status
barRadius: const BorderRadius.circular(10.0), // the contoller to change and listen to the bar status
side: Side.bottom, // Side.right is the default
clickerPosition: 1.0, // the position of the clicker, 0.0 is the default
clickerSize: 60, // the sizer of the default clicker, 55 is the default
onChange: (int index){
print(index);
// this will print the index of the widget you clicked inside the bar
print(index); // this will print the index of the widget you clicked inside the bar
},
duration: Duration(milliseconds: 500), // the duration of the animation, (300 mil) is the default
isOpenFirst: true, // the initial state of the bar, false is default
backgroundColor: Colors.black, // primary color is default
curve: Curves.ease, // the animation curve, linear is defualt
clicker: Icon(Icons.arrow_forward_ios), // this will build instead of the default clicker
);
)
```

## Getting started
Expand All @@ -40,7 +48,7 @@ In the `pubspec.yaml` of your flutter project, add the following dependency:

```yaml
dependencies:
slidable_bar: "^1.0.0"
slidable_bar: "^1.1.0"
```
Then run `$ flutter pub get`. In your library, add the following import:
Expand Down
51 changes: 38 additions & 13 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,51 @@ class App extends StatelessWidget {
}
}

class Example extends StatelessWidget {
class Example extends StatefulWidget {

@override
_ExampleState createState() => _ExampleState();
}

class _ExampleState extends State<Example> {

final SlidableBarController controller = SlidableBarController(initialStatus: true);

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('slidable bar example'),
),
body: SlidableBar(
width: 60,
frontColor: Colors.green,
backgroundColor: Colors.white,
barChildren: [
FlutterLogo(size: 50,),
FlutterLogo(size: 50,),
FlutterLogo(size: 50,),
FlutterLogo(size: 50,),
body: Column(
children: [
Container(
height: 210,
width: 300,
child: SlidableBar(
size: 60,
slidableController: controller,
side: Side.top,
barChildren: [
FlutterLogo(size: 50,),
FlutterLogo(size: 50,),
FlutterLogo(size: 50,),
FlutterLogo(size: 50,),
],
child: Container(
color: Colors.grey.shade200,
child: Center(
child: ElevatedButton(
child: Text("reverse status"),
onPressed: (){
controller.reverseStatus();
},
),
),
),
),
),
],
child: Container(
color: Colors.grey.shade200,
),
),
);
}
Expand Down
26 changes: 0 additions & 26 deletions example/test/widget_test.dart
Original file line number Diff line number Diff line change
@@ -1,30 +1,4 @@
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

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

import 'package:example/main.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());

// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);

// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();

// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
Loading

0 comments on commit 8897d9e

Please sign in to comment.