home.dart 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:hengyi/home/about_us.dart';
  4. import 'package:hengyi/home/contact_us.dart';
  5. import 'package:hengyi/home/country_list.dart';
  6. import 'package:hengyi/widget/common_footer.dart';
  7. import 'package:hengyi/widget/common_title.dart';
  8. import '../utils/common_util.dart';
  9. class HomePage extends StatefulWidget {
  10. HomePage({super.key});
  11. @override
  12. State<HomePage> createState() => _HomePageState();
  13. }
  14. class _HomePageState extends State<HomePage>
  15. with SingleTickerProviderStateMixin {
  16. late TabController _tabController;
  17. List tabs = ["了解目的地", "联系我们", "关于我们"];
  18. var tabBarTextSize = 0.0;
  19. @override
  20. void initState() {
  21. super.initState();
  22. if (Util.isWeb()) {
  23. tabBarTextSize = 30.sp;
  24. } else {
  25. tabBarTextSize = 60.sp;
  26. }
  27. _tabController = TabController(length: tabs.length, vsync: this);
  28. }
  29. @override
  30. Widget build(BuildContext context) {
  31. return Scaffold(
  32. body: Column(
  33. children: [
  34. CommonTitleWidget(),
  35. Material(
  36. color: Colors.grey[100],
  37. child: TabBar(
  38. padding: EdgeInsets.all(5),
  39. indicatorPadding: EdgeInsets.all(-5),
  40. labelColor: Colors.black,
  41. unselectedLabelColor: Colors.grey,
  42. controller: _tabController,
  43. tabs: tabs
  44. .map((e) => Tab(
  45. child: Text(
  46. e,
  47. style: TextStyle(fontSize: tabBarTextSize),
  48. )))
  49. .toList()),
  50. ),
  51. Expanded(
  52. child: TabBarView(
  53. controller: _tabController,
  54. children: [
  55. CountryListWidget(),
  56. ContactUSWidget(),
  57. AboutUSWidget(),
  58. ],
  59. )),
  60. CommonFooterWidget(),
  61. ],
  62. ),
  63. );
  64. }
  65. @override
  66. void dispose() {
  67. _tabController.dispose();
  68. super.dispose();
  69. }
  70. }