Răsfoiți Sursa

修改资产顶部tab 中文的时候 保持不滑动,其它语言保持原样滑动

yangjia 1 lună în urmă
părinte
comite
fc085936a8

+ 3 - 3
ios/Runner.xcodeproj/project.pbxproj

@@ -495,7 +495,7 @@
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
 				CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
-				DEVELOPMENT_TEAM = 9RL67B83R7;
+				DEVELOPMENT_TEAM = 3994VLPW3Z;
 				ENABLE_BITCODE = NO;
 				INFOPLIST_FILE = Runner/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = (
@@ -682,7 +682,7 @@
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
 				CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
-				DEVELOPMENT_TEAM = 9RL67B83R7;
+				DEVELOPMENT_TEAM = 3994VLPW3Z;
 				ENABLE_BITCODE = NO;
 				INFOPLIST_FILE = Runner/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = (
@@ -708,7 +708,7 @@
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
 				CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
-				DEVELOPMENT_TEAM = 9RL67B83R7;
+				DEVELOPMENT_TEAM = 3994VLPW3Z;
 				ENABLE_BITCODE = NO;
 				INFOPLIST_FILE = Runner/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = (

+ 201 - 129
lib/presentation/screens/asset/asset_screen.dart

@@ -136,44 +136,54 @@ class _AssetScreenState extends ConsumerState<AssetScreen>
   Widget build(BuildContext context) {
     final state = ref.watch(assetProvider);
     final notifier = ref.read(assetProvider.notifier);
+    final isChineseLocale =
+        Localizations.localeOf(context).languageCode == 'zh';
+    final tabs = _getLocalizedTabs(context);
 
     return Scaffold(
       body: SafeArea(
-          child: Column(
-            children: [
-              // ── Tab 栏 ─────────────────────────────────────
-              TabBar(
+        child: Column(
+          children: [
+            // ── Tab 栏 ─────────────────────────────────────
+            TabBar(
+              controller: _tabController,
+              isScrollable: !isChineseLocale,
+              indicator: StretchTabIndicator(
                 controller: _tabController,
-                isScrollable: true,
-                indicator: StretchTabIndicator(
-                  controller: _tabController,
-                  color: AppColors.brand,
-                  height: 3,
-                  borderRadius: 1.5,
-                ),
-                indicatorSize: TabBarIndicatorSize.label,
-                labelStyle: const TextStyle(fontSize: 16, fontWeight: FontWeight.w700),
-                unselectedLabelStyle: const TextStyle(fontSize: 16, fontWeight: FontWeight.w400),
-                tabAlignment: TabAlignment.start,
-                dividerColor: Colors.transparent,
-                labelPadding: const EdgeInsets.symmetric(horizontal: 14),
-                padding: const EdgeInsets.fromLTRB(4, 8, 16, 0),
-                tabs: <Widget>[
-                  for (int i = 0; i < 6; i++)
-                    Semantics(
-                      label: _getTabLabel(i),
-                      button: true,
-                      child: Tab(text: _getLocalizedTabs(context)[i]),
-                    ),
-                ],
+                color: AppColors.brand,
+                height: 3,
+                borderRadius: 1.5,
               ),
+              indicatorSize: TabBarIndicatorSize.label,
+              labelStyle:
+                  const TextStyle(fontSize: 16, fontWeight: FontWeight.w700),
+              unselectedLabelStyle:
+                  const TextStyle(fontSize: 16, fontWeight: FontWeight.w400),
+              tabAlignment:
+                  isChineseLocale ? TabAlignment.fill : TabAlignment.start,
+              dividerColor: Colors.transparent,
+              labelPadding: isChineseLocale
+                  ? EdgeInsets.zero
+                  : const EdgeInsets.symmetric(horizontal: 14),
+              padding: isChineseLocale
+                  ? const EdgeInsets.only(top: 8)
+                  : const EdgeInsets.fromLTRB(4, 8, 16, 0),
+              tabs: <Widget>[
+                for (int i = 0; i < 6; i++)
+                  Semantics(
+                    label: _getTabLabel(i),
+                    button: true,
+                    child: Tab(text: tabs[i]),
+                  ),
+              ],
+            ),
 
-              // ── Tab 内容 ───────────────────────────────────
-              Expanded(
-                child: _buildContent(state, notifier),
-              ),
-            ],
-          ),
+            // ── Tab 内容 ───────────────────────────────────
+            Expanded(
+              child: _buildContent(state, notifier),
+            ),
+          ],
+        ),
       ),
     );
   }
@@ -229,34 +239,37 @@ class _AssetShimmer extends StatelessWidget {
             shimmerBox(120, 13),
             const SizedBox(height: 24),
             // 账户卡片列表
-            ...List.generate(3, (_) => Padding(
-              padding: const EdgeInsets.only(bottom: 12),
-              child: Container(
-                padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
-                decoration: BoxDecoration(
-                  color: Colors.white,
-                  borderRadius: BorderRadius.circular(12),
-                ),
-                child: Row(
-                  children: [
-                    shimmerCircle(22),
-                    const SizedBox(width: 12),
-                    shimmerBox(80, 14),
-                    const Spacer(),
-                    Column(
-                      crossAxisAlignment: CrossAxisAlignment.end,
-                      children: [
-                        shimmerBox(90, 15),
-                        const SizedBox(height: 4),
-                        shimmerBox(60, 12),
-                      ],
-                    ),
-                    const SizedBox(width: 8),
-                    shimmerBox(18, 18, radius: 4),
-                  ],
-                ),
-              ),
-            )),
+            ...List.generate(
+                3,
+                (_) => Padding(
+                      padding: const EdgeInsets.only(bottom: 12),
+                      child: Container(
+                        padding: const EdgeInsets.symmetric(
+                            horizontal: 16, vertical: 16),
+                        decoration: BoxDecoration(
+                          color: Colors.white,
+                          borderRadius: BorderRadius.circular(12),
+                        ),
+                        child: Row(
+                          children: [
+                            shimmerCircle(22),
+                            const SizedBox(width: 12),
+                            shimmerBox(80, 14),
+                            const Spacer(),
+                            Column(
+                              crossAxisAlignment: CrossAxisAlignment.end,
+                              children: [
+                                shimmerBox(90, 15),
+                                const SizedBox(height: 4),
+                                shimmerBox(60, 12),
+                              ],
+                            ),
+                            const SizedBox(width: 8),
+                            shimmerBox(18, 18, radius: 4),
+                          ],
+                        ),
+                      ),
+                    )),
             const SizedBox(height: 8),
             // 持仓卡片
             Container(
@@ -274,7 +287,8 @@ class _AssetShimmer extends StatelessWidget {
                   const SizedBox(height: 12),
                   Row(
                     mainAxisAlignment: MainAxisAlignment.spaceBetween,
-                    children: List.generate(3, (_) => shimmerBox(70, 40, radius: 6)),
+                    children:
+                        List.generate(3, (_) => shimmerBox(70, 40, radius: 6)),
                   ),
                 ],
               ),
@@ -300,7 +314,8 @@ class AssetHeader extends StatelessWidget {
   Widget build(BuildContext context) {
     final cs = Theme.of(context).colorScheme;
     final total = state.totalUsdtValue;
-    final display = state.obscureBalance ? '******' : formatPrice(total, decimalPlaces: 2);
+    final display =
+        state.obscureBalance ? '******' : formatPrice(total, decimalPlaces: 2);
 
     return Padding(
       padding: const EdgeInsets.fromLTRB(16, 20, 16, 0),
@@ -309,7 +324,9 @@ class AssetHeader extends StatelessWidget {
         children: [
           Row(
             children: [
-              Text(AppLocalizations.of(context)!.assetValuation, style: TextStyle(color: cs.onSurface.withAlpha(153), fontSize: 13)),
+              Text(AppLocalizations.of(context)!.assetValuation,
+                  style: TextStyle(
+                      color: cs.onSurface.withAlpha(153), fontSize: 13)),
               const SizedBox(width: 6),
               Semantics(
                 label: 'asset_btn_toggle_balance',
@@ -319,8 +336,11 @@ class AssetHeader extends StatelessWidget {
                 child: GestureDetector(
                   onTap: notifier.toggleObscure,
                   child: Icon(
-                    state.obscureBalance ? Icons.visibility_off_outlined : Icons.visibility_outlined,
-                    size: 16, color: cs.onSurface.withAlpha(153),
+                    state.obscureBalance
+                        ? Icons.visibility_off_outlined
+                        : Icons.visibility_outlined,
+                    size: 16,
+                    color: cs.onSurface.withAlpha(153),
                   ),
                 ),
               ),
@@ -333,7 +353,12 @@ class AssetHeader extends StatelessWidget {
               Semantics(
                 label: 'asset_text_total_value',
                 enabled: true,
-                child: Text(display, style: TextStyle(color: cs.onSurface, fontSize: 32, fontWeight: FontWeight.w700, letterSpacing: -0.5)),
+                child: Text(display,
+                    style: TextStyle(
+                        color: cs.onSurface,
+                        fontSize: 32,
+                        fontWeight: FontWeight.w700,
+                        letterSpacing: -0.5)),
               ),
               const SizedBox(width: 6),
               Semantics(
@@ -341,7 +366,9 @@ class AssetHeader extends StatelessWidget {
                 enabled: true,
                 child: Padding(
                   padding: const EdgeInsets.only(bottom: 5),
-                  child: Text('USDT', style: TextStyle(color: cs.onSurface.withAlpha(153), fontSize: 14)),
+                  child: Text('USDT',
+                      style: TextStyle(
+                          color: cs.onSurface.withAlpha(153), fontSize: 14)),
                 ),
               ),
             ],
@@ -391,7 +418,9 @@ class AssetPositionCard extends StatelessWidget {
       decoration: BoxDecoration(
         color: isDark ? AppColors.darkBgSecondary : AppColors.lightBgSecondary,
         borderRadius: BorderRadius.circular(12),
-        border: isDark ? null : Border.all(color: AppColors.lightBorder, width: 0.5),
+        border: isDark
+            ? null
+            : Border.all(color: AppColors.lightBorder, width: 0.5),
       ),
       child: Column(
         crossAxisAlignment: CrossAxisAlignment.start,
@@ -400,15 +429,27 @@ class AssetPositionCard extends StatelessWidget {
           Row(
             children: [
               Container(
-                width: 32, height: 32,
-                decoration: BoxDecoration(color: sideColor, borderRadius: BorderRadius.circular(8)),
+                width: 32,
+                height: 32,
+                decoration: BoxDecoration(
+                    color: sideColor, borderRadius: BorderRadius.circular(8)),
                 child: Center(
-                  child: Text(isLong ? AppLocalizations.of(context)!.longLabel : AppLocalizations.of(context)!.shortLabel,
-                      style: const TextStyle(color: Colors.white, fontSize: 13, fontWeight: FontWeight.w700)),
+                  child: Text(
+                      isLong
+                          ? AppLocalizations.of(context)!.longLabel
+                          : AppLocalizations.of(context)!.shortLabel,
+                      style: const TextStyle(
+                          color: Colors.white,
+                          fontSize: 13,
+                          fontWeight: FontWeight.w700)),
                 ),
               ),
               const SizedBox(width: 10),
-              Text(symbol, style: TextStyle(color: cs.onSurface, fontSize: 15, fontWeight: FontWeight.w600)),
+              Text(symbol,
+                  style: TextStyle(
+                      color: cs.onSurface,
+                      fontSize: 15,
+                      fontWeight: FontWeight.w600)),
               const SizedBox(width: 8),
               _Tag(label: AppLocalizations.of(context)!.perpetual),
               const SizedBox(width: 4),
@@ -420,12 +461,17 @@ class AssetPositionCard extends StatelessWidget {
                   color: cs.onSurface.withAlpha(20),
                   borderRadius: BorderRadius.circular(4),
                 ),
-                child: Text(leverage, style: TextStyle(color: cs.onSurface, fontSize: 11, fontWeight: FontWeight.w600)),
+                child: Text(leverage,
+                    style: TextStyle(
+                        color: cs.onSurface,
+                        fontSize: 11,
+                        fontWeight: FontWeight.w600)),
               ),
               const Spacer(),
               GestureDetector(
                 onTap: onShare,
-                child: Icon(Icons.share_outlined, size: 18, color: cs.onSurface.withAlpha(153)),
+                child: Icon(Icons.share_outlined,
+                    size: 18, color: cs.onSurface.withAlpha(153)),
               ),
             ],
           ),
@@ -441,20 +487,32 @@ class AssetPositionCard extends StatelessWidget {
                 Column(
                   crossAxisAlignment: CrossAxisAlignment.start,
                   children: [
-                    Text('${AppLocalizations.of(context)!.unrealizedPnl} (USDT)', style: TextStyle(color: cs.onSurface.withAlpha(153), fontSize: 11)),
+                    Text(
+                        '${AppLocalizations.of(context)!.unrealizedPnl} (USDT)',
+                        style: TextStyle(
+                            color: cs.onSurface.withAlpha(153), fontSize: 11)),
                     const SizedBox(height: 2),
                     Text(
                       obscure ? '******' : pnl,
-                      style: TextStyle(color: effectivePnlColor, fontSize: 20, fontWeight: FontWeight.w700),
+                      style: TextStyle(
+                          color: effectivePnlColor,
+                          fontSize: 20,
+                          fontWeight: FontWeight.w700),
                     ),
                   ],
                 ),
                 Column(
                   crossAxisAlignment: CrossAxisAlignment.end,
                   children: [
-                    Text(AppLocalizations.of(context)!.returnRate, style: TextStyle(color: cs.onSurface.withAlpha(153), fontSize: 11)),
+                    Text(AppLocalizations.of(context)!.returnRate,
+                        style: TextStyle(
+                            color: cs.onSurface.withAlpha(153), fontSize: 11)),
                     const SizedBox(height: 2),
-                    Text(roi, style: TextStyle(color: effectivePnlColor, fontSize: 16, fontWeight: FontWeight.w600)),
+                    Text(roi,
+                        style: TextStyle(
+                            color: effectivePnlColor,
+                            fontSize: 16,
+                            fontWeight: FontWeight.w600)),
                   ],
                 ),
               ],
@@ -496,57 +554,66 @@ class AssetAccountRow extends StatelessWidget {
       onTap: onTap,
       behavior: HitTestBehavior.opaque,
       child: Container(
-      padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
-      decoration: BoxDecoration(
-        color: isDark ? AppColors.darkBgSecondary : AppColors.lightBgSecondary,
-        borderRadius: BorderRadius.circular(12),
-        border: isDark ? null : Border.all(color: AppColors.lightBorder, width: 0.5),
-      ),
-      child: Row(
-        children: [
-          Icon(icon, color: cs.onSurface.withAlpha(153), size: 22),
-          const SizedBox(width: 12),
-          Expanded(
-            child: Text(label,
-                style: TextStyle(
-                    color: cs.onSurface,
-                    fontSize: 14,
-                    fontWeight: FontWeight.w500)),
-          ),
-          if (onTransfer != null) ...[
-            OutlinedButton(
-              onPressed: onTransfer,
-              style: OutlinedButton.styleFrom(
-                side: const BorderSide(color: AppColors.brand),
-                foregroundColor: AppColors.brand,
-                minimumSize: const Size(0, 32),
-                padding: const EdgeInsets.symmetric(horizontal: 12),
-                tapTargetSize: MaterialTapTargetSize.shrinkWrap,
-              ),
-              child: Text(
-                AppLocalizations.of(context)!.transfer,
-                style: const TextStyle(fontSize: 12),
+        padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
+        decoration: BoxDecoration(
+          color:
+              isDark ? AppColors.darkBgSecondary : AppColors.lightBgSecondary,
+          borderRadius: BorderRadius.circular(12),
+          border: isDark
+              ? null
+              : Border.all(color: AppColors.lightBorder, width: 0.5),
+        ),
+        child: Row(
+          children: [
+            Icon(icon, color: cs.onSurface.withAlpha(153), size: 22),
+            const SizedBox(width: 12),
+            Expanded(
+              child: Text(label,
+                  style: TextStyle(
+                      color: cs.onSurface,
+                      fontSize: 14,
+                      fontWeight: FontWeight.w500)),
+            ),
+            if (onTransfer != null) ...[
+              OutlinedButton(
+                onPressed: onTransfer,
+                style: OutlinedButton.styleFrom(
+                  side: const BorderSide(color: AppColors.brand),
+                  foregroundColor: AppColors.brand,
+                  minimumSize: const Size(0, 32),
+                  padding: const EdgeInsets.symmetric(horizontal: 12),
+                  tapTargetSize: MaterialTapTargetSize.shrinkWrap,
+                ),
+                child: Text(
+                  AppLocalizations.of(context)!.transfer,
+                  style: const TextStyle(fontSize: 12),
+                ),
               ),
+              const SizedBox(width: 12),
+            ],
+            Column(
+              crossAxisAlignment: CrossAxisAlignment.end,
+              children: [
+                Text(amount,
+                    style: TextStyle(
+                        color: cs.onSurface,
+                        fontSize: 15,
+                        fontWeight: FontWeight.w600)),
+                if (usdAmount.isNotEmpty)
+                  Text(usdAmount,
+                      style: TextStyle(
+                          color: cs.onSurface.withAlpha(120), fontSize: 12)),
+              ],
+            ),
+            const SizedBox(width: 8),
+            Icon(
+              Icons.chevron_right,
+              size: 18,
+              color: cs.onSurface.withAlpha(102),
             ),
-            const SizedBox(width: 12),
           ],
-          Column(
-            crossAxisAlignment: CrossAxisAlignment.end,
-            children: [
-              Text(amount, style: TextStyle(color: cs.onSurface, fontSize: 15, fontWeight: FontWeight.w600)),
-              if (usdAmount.isNotEmpty)
-                Text(usdAmount, style: TextStyle(color: cs.onSurface.withAlpha(120), fontSize: 12)),
-            ],
-          ),
-          const SizedBox(width: 8),
-          Icon(
-            Icons.chevron_right,
-            size: 18,
-            color: cs.onSurface.withAlpha(102),
-          ),
-        ],
+        ),
       ),
-    ),
     );
   }
 }
@@ -566,7 +633,8 @@ class _Tag extends StatelessWidget {
         border: Border.all(color: cs.onSurface.withAlpha(60)),
         borderRadius: BorderRadius.circular(4),
       ),
-      child: Text(label, style: TextStyle(color: cs.onSurface.withAlpha(153), fontSize: 10)),
+      child: Text(label,
+          style: TextStyle(color: cs.onSurface.withAlpha(153), fontSize: 10)),
     );
   }
 }
@@ -595,7 +663,8 @@ class _DataGrid extends StatelessWidget {
                             : CrossAxisAlignment.center,
                     children: [
                       Text(row[i],
-                          style: TextStyle(color: cs.onSurface.withAlpha(120), fontSize: 11),
+                          style: TextStyle(
+                              color: cs.onSurface.withAlpha(120), fontSize: 11),
                           textAlign: i == 0
                               ? TextAlign.left
                               : i + 2 >= row.length
@@ -604,7 +673,10 @@ class _DataGrid extends StatelessWidget {
                       const SizedBox(height: 2),
                       Text(
                         obscure ? '***' : row[i + 1],
-                        style: TextStyle(color: cs.onSurface, fontSize: 13, fontWeight: FontWeight.w500),
+                        style: TextStyle(
+                            color: cs.onSurface,
+                            fontSize: 13,
+                            fontWeight: FontWeight.w500),
                         textAlign: i == 0
                             ? TextAlign.left
                             : i + 2 >= row.length