Skip to content

Commit

Permalink
隐藏TabBar点击效果方法更新
Browse files Browse the repository at this point in the history
  • Loading branch information
simplezhli committed Sep 14, 2024
1 parent 1c97a82 commit ea9f3a0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 52 deletions.
9 changes: 6 additions & 3 deletions lib/goods/page/goods_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ class _GoodsPageState extends State<GoodsPage> with SingleTickerProviderStateMix
),
),
Gaps.vGap24,
Container(
// 隐藏点击效果
Padding(
padding: const EdgeInsets.only(left: 16.0),
color: context.backgroundColor,
child: TabBar(
onTap: (index) {
if (!mounted) {
Expand All @@ -139,6 +137,11 @@ class _GoodsPageState extends State<GoodsPage> with SingleTickerProviderStateMix
unselectedLabelColor: context.isDark ? Colours.text_gray : Colours.text,
labelColor: Theme.of(context).primaryColor,
indicatorPadding: const EdgeInsets.only(right: 98.0 - 36.0),
// 隐藏点击效果
overlayColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
return Colors.transparent;
},
),
tabs: const <Widget>[
_TabView('在售', 0),
_TabView('待售', 1),
Expand Down
48 changes: 24 additions & 24 deletions lib/goods/widgets/goods_sort_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,31 +63,31 @@ class GoodsSortBottomSheetState extends State<GoodsSortBottomSheet> with SingleT
children: <Widget>[
child!,
Gaps.line,
ColoredBox(
TabBar(
controller: _tabController,
isScrollable: true,
onTap: (index) {
if (provider.myTabs[index].text.nullSafe.isEmpty) {
// 拦截点击事件
_tabController?.animateTo(provider.index);
return;
}
provider.setList(index);
provider.setIndex(index);
_controller.animateTo(
provider.positions[provider.index] * 48.0,
duration: const Duration(milliseconds: 10),
curve: Curves.ease,
);
},
indicatorSize: TabBarIndicatorSize.label,
unselectedLabelColor: context.isDark ? Colours.text_gray : Colours.text,
labelColor: Theme.of(context).primaryColor,
// 隐藏点击效果
color: context.dialogBackgroundColor,
child: TabBar(
controller: _tabController,
isScrollable: true,
onTap: (index) {
if (provider.myTabs[index].text.nullSafe.isEmpty) {
// 拦截点击事件
_tabController?.animateTo(provider.index);
return;
}
provider.setList(index);
provider.setIndex(index);
_controller.animateTo(
provider.positions[provider.index] * 48.0,
duration: const Duration(milliseconds: 10),
curve: Curves.ease,
);
},
indicatorSize: TabBarIndicatorSize.label,
unselectedLabelColor: context.isDark ? Colours.text_gray : Colours.text,
labelColor: Theme.of(context).primaryColor,
tabs: provider.myTabs,
),
overlayColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
return Colors.transparent;
},),
tabs: provider.myTabs,
),
Gaps.line,
Expanded(
Expand Down
20 changes: 0 additions & 20 deletions macos/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@
E19D36BBE941C0EC3CF86BFB /* Pods-Runner.release.xcconfig */,
9C7621F7B4CD9D86D2CF5117 /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
Expand All @@ -183,7 +182,6 @@
33CC10EA2044A3C60003C045 /* Frameworks */,
33CC10EB2044A3C60003C045 /* Resources */,
33CC110E2044A8840003C045 /* Bundle Framework */,
3399D490228B24CF009A79C7 /* ShellScript */,
B2092651FB09C4FF4658E668 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
Expand Down Expand Up @@ -254,24 +252,6 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
3399D490228B24CF009A79C7 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n";
};
33CC111E2044C6BF0003C045 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
10 changes: 5 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ homepage: https://weilu.blog.csdn.net/
publish_to: 'none'

environment:
sdk: ">=3.0.0-0 <4.0.0"
flutter: ">=3.7.0"
sdk: ">=3.4.0 <4.0.0"
flutter: ">=3.19.0"

dependencies:
flutter:
Expand All @@ -23,7 +23,7 @@ dependencies:
# Toast插件 https://github.com/OpenFlutter/flutter_oktoast
oktoast: ^3.4.0
# 网络库 https://github.com/cfug/dio
dio: ^5.5.0+1
dio: ^5.7.0
# https://github.com/ReactiveX/rxdart
rxdart: ^0.28.0
# Dart 常用工具类库 https://github.com/Sky24n/common_utils
Expand Down Expand Up @@ -61,8 +61,8 @@ dependencies:
# App Shortcuts https://github.com/flutter/packages/tree/main/packages/quick_actions
quick_actions: 1.0.7
# 振动 https://github.com/benjamindean/flutter_vibration
vibration: 1.9.0
vibration_web: 1.6.7
vibration: 2.0.0
vibration_web: 1.6.8
# 获取当前设备信息 https://github.com/fluttercommunity/plus_plugins/tree/main/packages/device_info_plus
device_info_plus: 10.0.1
# 桌面应用调整窗口的大小和位置 https://github.com/leanflutter/window_manager
Expand Down

0 comments on commit ea9f3a0

Please sign in to comment.