2021-02-02 14:33:23 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
import 'package:flutter_translate/flutter_translate.dart';
|
|
|
|
|
|
|
|
import '../shared/app_colors.dart';
|
|
|
|
import 'login_view.dart';
|
|
|
|
|
|
|
|
class AnonymousTabBarView extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
AnonymousTabBarState createState() => AnonymousTabBarState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class AnonymousTabBarState extends State<AnonymousTabBarView> with SingleTickerProviderStateMixin {
|
2021-11-29 23:44:22 +00:00
|
|
|
TabController? _tabController;
|
2021-02-02 14:33:23 +00:00
|
|
|
int _currentTabIndex = 0;
|
|
|
|
|
|
|
|
List<Widget> _realPages = [LoginView()];
|
|
|
|
List<Widget> _tabPages = [LoginView()];
|
|
|
|
List<bool> _hasInit = [true];
|
|
|
|
|
2021-04-05 20:06:54 +00:00
|
|
|
List<Widget> _tabsButton = [
|
|
|
|
Tab(
|
|
|
|
icon: Icon(Icons.person_outline, color: blueColor),
|
|
|
|
child: Text(
|
|
|
|
translate('tabs.login'),
|
|
|
|
style: TextStyle(color: blueColor),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
];
|
2021-02-02 14:33:23 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_tabController = TabController(length: _realPages.length, vsync: this)
|
|
|
|
..addListener(() {
|
2021-11-29 23:44:22 +00:00
|
|
|
int selectedIndex = _tabController!.index;
|
2021-02-02 14:33:23 +00:00
|
|
|
if (_currentTabIndex != selectedIndex) {
|
|
|
|
if (!_hasInit[selectedIndex]) {
|
|
|
|
_tabPages[selectedIndex] = _realPages[selectedIndex];
|
|
|
|
_hasInit[selectedIndex] = true;
|
|
|
|
}
|
|
|
|
setState(() => _currentTabIndex = selectedIndex);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
2021-11-29 23:44:22 +00:00
|
|
|
_tabController!.dispose();
|
2021-02-02 14:33:23 +00:00
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
body: IndexedStack(index: _currentTabIndex, children: _tabPages),
|
|
|
|
bottomNavigationBar: BottomAppBar(
|
|
|
|
child: TabBar(
|
|
|
|
labelColor: primaryAccentColor,
|
2021-04-05 20:06:54 +00:00
|
|
|
indicatorColor: blueColor,
|
2021-04-03 12:30:55 +00:00
|
|
|
indicatorWeight: 3.0,
|
2021-02-02 14:33:23 +00:00
|
|
|
tabs: _tabsButton,
|
|
|
|
controller: _tabController,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|