feat: 浮动 Dock TabBar 样式 (圆角胶囊 + 阴影 + 深色覆盖)

This commit is contained in:
2026-07-08 11:38:14 +08:00
parent 813c322249
commit 477f052cbd
2 changed files with 79 additions and 58 deletions
+15 -13
View File
@@ -1,37 +1,39 @@
<view class="tab-bar" style="{{themeStyle}}"> <view class="dock" style="{{themeStyle}}">
<view class="dock-inner">
<view <view
class="tab-item {{selected === 0 ? 'active' : ''}}" class="dock-item {{selected === 0 ? 'active' : ''}}"
data-index="0" data-index="0"
bindtap="switchTab" bindtap="switchTab"
> >
<view class="tab-icon" style="background-image: url({{selected === 0 ? svgIcons.homeFill : svgIcons.home}})"></view> <view class="dock-icon" style="background-image: url({{selected === 0 ? svgIcons.homeFill : svgIcons.home}})"></view>
<text class="tab-text">训练</text> <text class="dock-text">训练</text>
</view> </view>
<view <view
class="tab-item {{selected === 1 ? 'active' : ''}}" class="dock-item {{selected === 1 ? 'active' : ''}}"
data-index="1" data-index="1"
bindtap="switchTab" bindtap="switchTab"
> >
<view class="tab-icon" style="background-image: url({{selected === 1 ? svgIcons.calendarFill : svgIcons.calendar}})"></view> <view class="dock-icon" style="background-image: url({{selected === 1 ? svgIcons.calendarFill : svgIcons.calendar}})"></view>
<text class="tab-text">记录</text> <text class="dock-text">记录</text>
</view> </view>
<view <view
class="tab-item {{selected === 2 ? 'active' : ''}}" class="dock-item {{selected === 2 ? 'active' : ''}}"
data-index="2" data-index="2"
bindtap="switchTab" bindtap="switchTab"
> >
<view class="tab-icon" style="background-image: url({{selected === 2 ? svgIcons.rankFill : svgIcons.rank}})"></view> <view class="dock-icon" style="background-image: url({{selected === 2 ? svgIcons.rankFill : svgIcons.rank}})"></view>
<text class="tab-text">排行</text> <text class="dock-text">排行</text>
</view> </view>
<view <view
class="tab-item {{selected === 3 ? 'active' : ''}}" class="dock-item {{selected === 3 ? 'active' : ''}}"
data-index="3" data-index="3"
bindtap="switchTab" bindtap="switchTab"
> >
<view class="tab-icon" style="background-image: url({{selected === 3 ? svgIcons.settingsFill : svgIcons.settings}})"></view> <view class="dock-icon" style="background-image: url({{selected === 3 ? svgIcons.settingsFill : svgIcons.settings}})"></view>
<text class="tab-text">设置</text> <text class="dock-text">设置</text>
</view>
</view> </view>
</view> </view>
+45 -26
View File
@@ -1,54 +1,73 @@
.tab-bar { .dock {
position: fixed; position: fixed;
bottom: 0; bottom: calc(40rpx + env(safe-area-inset-bottom));
left: 0; left: 50%;
right: 0; transform: translateX(-50%);
height: calc(110rpx + env(safe-area-inset-bottom)); width: calc(100% - 80rpx);
background: #FFFFFF; max-width: 600rpx;
z-index: 100;
}
.dock-inner {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-around; justify-content: space-around;
border-top: 1rpx solid rgba(0, 0, 0, 0.06); background: var(--card-bg, #FFFFFF);
padding-bottom: env(safe-area-inset-bottom); border-radius: 100rpx;
z-index: 999; padding: 12rpx 0;
box-sizing: border-box; box-shadow:
overflow: hidden; 0 8rpx 32rpx rgba(0, 0, 0, 0.12),
0 2rpx 8rpx rgba(0, 0, 0, 0.06);
transition: background-color 0.3s ease;
} }
.tab-item { .dock-item {
flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding: 4rpx 0; padding: 8rpx 0;
flex: 1; transition: transform 0.2s ease;
min-width: 0;
height: 100%;
box-sizing: border-box;
} }
.tab-item:active { .dock-item:active {
transform: scale(0.92); transform: scale(0.92);
} }
.tab-icon { .dock-icon {
width: 44rpx; width: 44rpx;
height: 44rpx; height: 44rpx;
background-size: contain; background-size: contain;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center; background-position: center;
margin-bottom: 4rpx; margin-bottom: 4rpx;
flex-shrink: 0; opacity: 0.5;
transition: opacity 0.2s ease;
} }
.tab-text { .dock-text {
font-size: 22rpx; font-size: 20rpx;
color: var(--text-secondary); color: var(--text-secondary, #999);
line-height: 1; line-height: 1;
white-space: nowrap; transition: color 0.2s ease;
} }
.tab-item.active .tab-text { .dock-item.active .dock-icon {
color: var(--primary); opacity: 1;
}
.dock-item.active .dock-text {
color: var(--primary, #FF6B35);
font-weight: 600; font-weight: 600;
} }
/* dark mode */
@media (prefers-color-scheme: dark) {
.dock-inner {
background: var(--card-bg, #1C1C1E);
box-shadow:
0 8rpx 32rpx rgba(0, 0, 0, 0.5),
0 2rpx 8rpx rgba(0, 0, 0, 0.3);
}
}