main_ticketer_view.dart
3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../common/colors.dart';
import '../../component/KeepAliveWrapper.dart';
import 'main_ticketer_logic.dart';
import 'package:cp_offline_manage/pages/home/home_ticketer_main/home_ticketer_main_view.dart';
import 'package:cp_offline_manage/pages/me/me_main/me_main_view.dart';
class Main_ticketerPage extends GetView<Main_ticketerLogic> {
Main_ticketerPage({Key? key}) : super(key: key);
//首页
BottomNavigationBarItem _buildHomeTabBarItem() {
return BottomNavigationBarItem(
backgroundColor: Colors.orange,
icon: Image(
image: AssetImage(controller.currentIndex.value == 0
? selectIcon[0]
: unSelectIcon[0]),
width: 24,
height: 24,
),
label: "首页");
}
//我的
BottomNavigationBarItem _buildUserTabBarItem() {
return BottomNavigationBarItem(
backgroundColor: Colors.orange,
icon: Stack(
clipBehavior: Clip.none,
children: [
Image(
image: AssetImage(controller.currentIndex.value == 1
? selectIcon[1]
: unSelectIcon[1]),
width: 24,
height: 24,
),
controller.userDotCount.value > 0
? Positioned(
top: -4.0,
right: -6.0,
child: Container(
padding: const EdgeInsets.all(1),
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(7),
),
constraints: const BoxConstraints(
minWidth: 14,
minHeight: 14,
),
child: Text(
'${controller.userDotCount.value < 100 ? controller.userDotCount.value : "99+"}',
style: const TextStyle(
color: Colors.white,
fontSize: 8,
),
textAlign: TextAlign.center,
),
))
: const SizedBox(height: 0.0, width: 0.0)
],
),
label: "我的",
);
}
final pages = [
KeepAliveWrapper(child: Home_ticketer_mainPage()),
KeepAliveWrapper(child: Me_mainPage())
];
final selectIcon = [
"assets/images/bottom_icon/icon_zhuye_n.png",
"assets/images/bottom_icon/icon_geren_n.png",
];
final unSelectIcon = [
"assets/images/bottom_icon/icon_zhuye_s.png",
"assets/images/bottom_icon/icon_geren_s.png",
];
@override
Widget build(BuildContext context) {
final logic = Get.put(Main_ticketerLogic());
return Scaffold(
bottomNavigationBar: Obx(() => BottomNavigationBar(
items: [_buildHomeTabBarItem(), _buildUserTabBarItem()],
currentIndex: controller.currentIndex.value,
type: BottomNavigationBarType.fixed,
onTap: (index) => controller.onTabChange(index),
selectedFontSize: 13,
unselectedFontSize: 13,
)),
body: PageView.builder(
controller: controller.pageController,
physics: const NeverScrollableScrollPhysics(),
itemCount: pages.length,
itemBuilder: (context, index) => pages[index]));
}
}