Skip to content

Commit

Permalink
Merge pull request #21 from MarsadMaqsood/main
Browse files Browse the repository at this point in the history
updated
  • Loading branch information
MarsadMaqsood authored Nov 9, 2023
2 parents 62981e8 + 0671ed1 commit 94ad2b7
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 2 deletions.
30 changes: 29 additions & 1 deletion test/stylish_bottom_bar_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';

import 'test_file.dart';

void main() {
Expand All @@ -16,4 +15,33 @@ void main() {
await tester.pumpAndSettle();
expect(find.byIcon(Icons.star_border_rounded), findsOneWidget);
});

testWidgets('Test BubbleBarExample', (WidgetTester tester) async {
// Create and pump AnimatedBarExample widget to test.
await tester.pumpWidget(const MaterialApp(home: BubbelBarExample()));

// Check if the "Home" icon is displayed.
expect(find.byIcon(Icons.abc), findsNothing);

// Tap on the "Star" tab and check if the "Star" icon is displayed.
await tester.tap(find.byIcon(Icons.read_more));
await tester.pumpAndSettle();
expect(find.byIcon(Icons.star_border_rounded), findsNothing);
});

testWidgets('Test DotBarExample', (WidgetTester tester) async {
// Create and pump AnimatedBarExample widget to test.
await tester.pumpWidget(const MaterialApp(home: DotBarExample()));

// Wait for the widget to be rendered.
await tester.idle();

expect(find.byWidget(const Text('Home')), findsNothing);

// Wait for the widget to be updated.
await tester.pumpAndSettle();

// Check if the "Star" icon and title are displayed.
expect(find.text('Star'), findsOneWidget);
});
}
111 changes: 110 additions & 1 deletion test/test_file.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,117 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:stylish_bottom_bar/model/bar_items.dart';
import 'package:stylish_bottom_bar/stylish_bottom_bar.dart';

class DotBarExample extends StatefulWidget {
const DotBarExample({super.key});

@override
State<DotBarExample> createState() => _DotBarExampleState();
}

class _DotBarExampleState extends State<DotBarExample> {
dynamic selected;
var heart = false;
PageController controller = PageController();

@override
void dispose() {
controller.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Scaffold(
extendBody: true, //to make floating action button notch transparent

//to avoid the floating action button overlapping behavior,
// when a soft keyboard is displayed
// resizeToAvoidBottomInset: false,

bottomNavigationBar: StylishBottomBar(
option: DotBarOptions(),
items: [
BottomBarItem(
icon: const Icon(
Icons.house_outlined,
),
selectedIcon: const Icon(Icons.house_rounded),
// selectedColor: Colors.teal,
backgroundColor: Colors.teal,
title: const Text('Home'),
badge: const Text('9+'),
showBadge: true,
badgeColor: Colors.purple,
badgePadding: const EdgeInsets.only(left: 4, right: 4),
),
BottomBarItem(
icon: const Icon(Icons.star_border_rounded),
selectedIcon: const Icon(Icons.star_rounded),
selectedColor: Colors.red,
// unSelectedColor: Colors.purple,
// backgroundColor: Colors.orange,
title: const Text('Star'),
),
BottomBarItem(
icon: const Icon(
Icons.style_outlined,
),
selectedIcon: const Icon(
Icons.style,
),
backgroundColor: Colors.amber,
selectedColor: Colors.deepOrangeAccent,
title: const Text('Style')),
BottomBarItem(
icon: const Icon(
Icons.person_outline,
),
selectedIcon: const Icon(
Icons.person,
),
backgroundColor: Colors.purpleAccent,
selectedColor: Colors.deepPurple,
title: const Text('Profile')),
],
hasNotch: true,
fabLocation: StylishBarFabLocation.center,
currentIndex: selected ?? 0,
onTap: (index) {
controller.jumpToPage(index);
setState(() {
selected = index;
});
},
),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {
heart = !heart;
});
},
backgroundColor: Colors.white,
child: Icon(
heart ? CupertinoIcons.heart_fill : CupertinoIcons.heart,
color: Colors.red,
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
body: SafeArea(
child: PageView(
controller: controller,
children: const [
Center(child: Text('Home')),
Center(child: Text('Star')),
Center(child: Text('Style')),
Center(child: Text('Profile')),
],
),
),
);
}
}

class AnimatedBarExample extends StatefulWidget {
const AnimatedBarExample({super.key});

Expand Down

0 comments on commit 94ad2b7

Please sign in to comment.