You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HMG_Patient_App/lib/pages/rapid-response-team/rrt-main-screen.dart

77 lines
2.2 KiB
Dart

5 years ago
import 'package:diplomaticquarterapp/pages/rapid-response-team/rrt-logs-page.dart';
import 'package:diplomaticquarterapp/pages/rapid-response-team/rrt-request-page.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class RRTMainScreen extends StatefulWidget{
@override
State<StatefulWidget> createState() => RRTMainScreenState();
}
class RRTMainScreenState extends State<RRTMainScreen> with SingleTickerProviderStateMixin{
int currentIndex = 0;
TabController tabController;
PageController pageController = PageController(initialPage: 0);
@override
void initState() {
super.initState();
tabController = TabController(length: 2, vsync: this);
}
@override
Widget build(BuildContext context) {
return AppScaffold(
appBarTitle: 'Rapid Response Team',
isShowAppBar: true,
body: Column(
children: [
tabBar(),
Expanded(
child: contentPager()
)
],
),
);
}
Widget tabBar() => Container(
margin: EdgeInsets.only(left: 15, right: 15, top: 15),
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(10)),
child: TabBar(
onTap: onPageChanged,
indicatorWeight: 3,
indicatorColor: Color(0xFFc5272d),
isScrollable: false,
controller: tabController,
indicatorSize: TabBarIndicatorSize.label,
tabs: [
Tab(
child: Text("Rapid Response Team", style: TextStyle(color: Theme.of(context).appBarTheme.color),),
),
Tab(
child: Text("Order Log", style: TextStyle(color: Theme.of(context).appBarTheme.color),),
),
]
),
);
Widget contentPager() => PageView(
onPageChanged: onPageChanged,
controller: pageController,
children: [
RRTRequestPage(),
RRTLogPage(),
],
);
void onPageChanged(int index) {
pageController.animateToPage(index, duration: Duration(milliseconds: 200), curve: Curves.easeInOut);
tabController.animateTo(index);
}
}