Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class _MyHomePageState extends State<MyHomePage> {
],
initialSelection: 1,
key: bottomNavigationKey,
fontSize: 18,
onTabChangedListener: (position) {
setState(() {
currentPage = position;
Expand Down
5 changes: 5 additions & 0 deletions lib/fancy_bottom_navigation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class FancyBottomNavigation extends StatefulWidget {
this.activeIconColor,
this.inactiveIconColor,
this.textColor,
this.fontSize,
this.barBackgroundColor})
: assert(onTabChangedListener != null),
assert(tabs != null),
Expand All @@ -32,6 +33,7 @@ class FancyBottomNavigation extends StatefulWidget {
final Color? activeIconColor;
final Color? inactiveIconColor;
final Color? textColor;
final double? fontSize;
final Color? barBackgroundColor;
final List<TabData> tabs;
final int initialSelection;
Expand All @@ -56,6 +58,7 @@ class FancyBottomNavigationState extends State<FancyBottomNavigation>
late Color inactiveIconColor;
late Color barBackgroundColor;
late Color textColor;
late double fontSize;

@override
void didChangeDependencies() {
Expand All @@ -81,6 +84,7 @@ class FancyBottomNavigationState extends State<FancyBottomNavigation>
((Theme.of(context).brightness == Brightness.dark)
? Colors.white
: Colors.black54);
fontSize = widget.fontSize ?? 12;
inactiveIconColor = (widget.inactiveIconColor) ??
((Theme.of(context).brightness == Brightness.dark)
? Colors.white
Expand Down Expand Up @@ -128,6 +132,7 @@ class FancyBottomNavigationState extends State<FancyBottomNavigation>
title: t.title,
iconColor: inactiveIconColor,
textColor: textColor,
fontSize: fontSize,
callbackFunction: (uniqueKey) {
int selected = widget.tabs
.indexWhere((tabData) => tabData.key == uniqueKey);
Expand Down
11 changes: 6 additions & 5 deletions lib/internal/tab_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:flutter/material.dart';

const double ICON_OFF = -3;
const double ICON_ON = 0;
const double TEXT_OFF = 3;
const double TEXT_ON = 1;
const double ALPHA_OFF = 0;
const double ALPHA_ON = 1;
Expand All @@ -16,7 +15,8 @@ class TabItem extends StatelessWidget {
required this.title,
required this.callbackFunction,
required this.textColor,
required this.iconColor});
required this.iconColor,
required this.fontSize});

final UniqueKey uniqueKey;
final String title;
Expand All @@ -25,9 +25,9 @@ class TabItem extends StatelessWidget {
final Function(UniqueKey uniqueKey) callbackFunction;
final Color textColor;
final Color iconColor;
final double fontSize;

final double iconYAlign = ICON_ON;
final double textYAlign = TEXT_OFF;
final double iconAlpha = ALPHA_ON;

@override
Expand All @@ -41,15 +41,16 @@ class TabItem extends StatelessWidget {
width: double.infinity,
child: AnimatedAlign(
duration: Duration(milliseconds: ANIM_DURATION),
alignment: Alignment(0, (selected) ? TEXT_ON : TEXT_OFF),
alignment: Alignment(0, (selected) ? TEXT_ON : 1 + fontSize / 2),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
title,
overflow: TextOverflow.ellipsis,
maxLines: 1,
style: TextStyle(
fontWeight: FontWeight.w600, color: textColor),
fontWeight: FontWeight.w600, color: textColor,
fontSize: fontSize),
),
)),
),
Expand Down