Widget _pageSelectTabWidget(BuildContext context, int index) {
return GestureDetector(
onTap: () {
if (currentTabIndex != index) {
currentTabIndex = index;
_pageController.animateToPage(currentTabIndex,
duration: const Duration(milliseconds: 300), curve: Curves.ease);
}
},
behavior: HitTestBehavior.opaque,
child: Container(
height: 89.w,
margin: EdgeInsetsDirectional.only(start: 24.w),
decoration: currentTabIndex == index
? BoxDecoration(
color: MyColor.colorFF1B1F25,
borderRadius: BorderRadius.circular(97.w))
: BoxDecoration(
color: MyColor.colorWhite,
border: Border.all(
color: const Color(0x1A272C35),
// 边框颜色 #1A272C35
width: 2.w, // 边框宽度 2.w
),
borderRadius: BorderRadius.circular(97.w),
),
padding: EdgeInsetsDirectional.only(start: 54.w, end: index==0?54.w:0.w),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
index == 0
? Text(
S.of(context).zp574,
style: TextStyle(
fontSize: 39.w,
color: index == currentTabIndex
? MyColor.colorFFFFFF
: MyColor.color272C35,
fontWeight: FontWeight.w500),
)
: Obx(() {
return Text(
logic.getTabKnowledgeTitle(
context, logic.currentKnowledgeIndex.value),
style: TextStyle(
fontSize: 39.w,
color: index == currentTabIndex
? MyColor.colorFFFFFF
: MyColor.color272C35,
fontWeight: FontWeight.w500),
);
}),
if (index == 1)
InkWidget(
onTap: () {
if (currentTabIndex != index) {
currentTabIndex = index;
_pageController.animateToPage(currentTabIndex,
duration: const Duration(milliseconds: 300), curve: Curves.ease);
}
showHomeBottomKnowledgeSelectDialog(
context: context,
index: logic.currentKnowledgeIndex.value,
onItemClick: (index) {
logic.currentKnowledgeIndex.value = index;
knowledgePageKey.currentState?.getDataByIndex(index);
});
},
child: Padding(padding: EdgeInsetsDirectional.only(start: 12.w,top: 12.w,bottom: 12.w,end: 54.w),
child: Image(
image: AssetImage(currentTabIndex == 1
? 'assets/images/ic_home_open_sel.webp'
: 'assets/images/ic_home_open_nor.webp'),
width: 30.w,
height: 30.w),)
)
],
),
),
);
}
Flutter 父控件与子控件响应事件
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 在子控件上同样添加手势 //父控件手势UITapGestureRecognizer *pan = [[UITapG...
- - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)e...
- 控件不能响应的情况: 1.userInteractionEnabled = NO 2.hidden = YES 3...