detail.dart 2.3 KB

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