How can keep convex_bottom_bar navigation if I go to new page #210
duc-airstage
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
`import '../generated/l10n.dart';
import 'bodygrum/bodygrum_page.dart';
import 'data/data_page.dart';
import 'running/running_page.dart';
import 'setting/setting_page.dart';
import 'top/top_page.dart';
import 'package:aircare_app/theme/color_theme.dart';
import 'package:airstage_skeleton/router.dart';
import 'package:convex_bottom_bar/convex_bottom_bar.dart';
import 'package:flutter/material.dart';
@RoutePage()
class MainPage extends StatefulWidget {
const MainPage({super.key});
@OverRide
State createState() => _MainPageState();
}
class _MainPageState extends State {
int currentIndex = 0;
int barIndex = 0;
List pages = [
const TopPage(),
const DataPage(),
const BodyGrumPage(),
const RunningPage(),
const SettingPage()
];
void onTap(int index) {
setState(() {
currentIndex = index;
});
}
@OverRide
Widget build(BuildContext context) {
return Scaffold(
// appBar: AppBar(
// systemOverlayStyle: SystemUiOverlayStyle.dark,
// backgroundColor: Colors.white,
// elevation: 0,
// toolbarHeight: 0,
// ),
body: pages[currentIndex],
bottomNavigationBar: StyleProvider(
style: ConvexStyleProvider(),
child: ConvexAppBar(
style: TabStyle.fixed,
backgroundColor: Colors.white,
color: textColorGray,
activeColor: textColorRed,
initialActiveIndex: 0,
cornerRadius: 30,
shadowColor: textColorGray,
height: 60,
items: [
TabItem(
icon: const ImageIcon(
AssetImage('assets/icons/top_nav_icon.png'),
),
title: S.of(context).nav_bottom_top,
isIconBlend: true,
),
TabItem(
icon: const ImageIcon(
AssetImage('assets/icons/data_nav_icon.png'),
),
title: S.of(context).nav_bottom_data,
isIconBlend: true,
),
TabItem(
icon: Container(
decoration: const BoxDecoration(
color: textColorRed,
shape: BoxShape.circle,
),
padding: const EdgeInsets.all(10),
child: const ImageIcon(
AssetImage('assets/icons/bodygrum_nav_icon.png'),
color: textColorWhite,
),
),
title: S.of(context).nav_bottom_body_grum,
isIconBlend: false,
),
TabItem(
icon: const ImageIcon(
AssetImage('assets/icons/running_nav_icon.png'),
),
title: S.of(context).nav_bottom_running,
isIconBlend: true,
),
TabItem(
icon: const ImageIcon(
AssetImage('assets/icons/setting_nav_icon.png'),
),
title: S.of(context).nav_bottom_setting,
isIconBlend: true,
),
],
onTap: onTap,
),
),
);
}
}
class ConvexStyleProvider extends StyleHook {
@OverRide
double get activeIconSize => 60;
@OverRide
double get activeIconMargin => 10;
@OverRide
double get iconSize => 30;
@OverRide
TextStyle textStyle(Color color, String? fontFamily) {
return TextStyle(fontSize: 12, color: color);
}
}
`
Beta Was this translation helpful? Give feedback.
All reactions