detail.dart 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import 'dart:math';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:fuwei/detail/country_detail.dart';
  5. import 'package:fuwei/home/about_us.dart';
  6. import 'package:fuwei/home/contact_us.dart';
  7. import 'package:fuwei/widget/common_footer.dart';
  8. import 'package:fuwei/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 = 30.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. padding: EdgeInsets.all(5),
  43. indicatorPadding: EdgeInsets.all(-5),
  44. labelColor: Colors.black,
  45. unselectedLabelColor: Colors.grey,
  46. controller: _tabController,
  47. onTap: (value) {
  48. if (value == 0) {
  49. Navigator.pop(context);
  50. }
  51. },
  52. tabs: tabs
  53. .map((e) => Tab(
  54. child: Text(
  55. e,
  56. style: TextStyle(fontSize: tabBarTextSize),
  57. )))
  58. .toList()),
  59. ),
  60. Expanded(
  61. child: TabBarView(
  62. controller: _tabController,
  63. children: [
  64. CountryDetailWidget(widget.countryId),
  65. ContactUSWidget(),
  66. AboutUSWidget(),
  67. ],
  68. )),
  69. CommonFooterWidget(),
  70. ],
  71. ),
  72. ),
  73. );
  74. }
  75. @override
  76. void dispose() {
  77. _tabController.dispose();
  78. super.dispose();
  79. }
  80. }