Ver Fonte

Update 优化个人中心页面居中

Yue há 3 semanas atrás
pai
commit
07b09fe0bb
1 ficheiros alterados com 52 adições e 48 exclusões
  1. 52 48
      UI/CF.APP/chicken_farm/lib/pages/home/profile.dart

+ 52 - 48
UI/CF.APP/chicken_farm/lib/pages/home/profile.dart

@@ -59,61 +59,65 @@ class ProfilePage extends ConsumerWidget {
       key: super.key,
       body: Padding(
         padding: const EdgeInsets.all(20),
-
-        child: SizedBox(
-          width: Platform.isAndroid ? MediaQuery.of(context).size.width : 300,
-          height: MediaQuery.of(context).size.height,
+        child: Center(  // 添加居中组件
           child: SingleChildScrollView(
-            child: Column(
-              crossAxisAlignment: CrossAxisAlignment.center,
-              mainAxisAlignment: MainAxisAlignment.center,
-              children: [
-                if (authState.state == AuthState.authenticated) ...[
-                  if (AppConfig.isOffline) ...[
-                    GestureDetector(
-                      onTap: handleUserCardTap,
-                      child: UserInfoCard(user: authState.user!),
-                    ),
-                    const SizedBox(height: 20),
-                    if (showDictConfig) ...[
-                      const DictConfigButton(),
+            child: SizedBox(
+              width: Platform.isAndroid 
+                  ? MediaQuery.of(context).size.width * 0.8  // 使用屏幕宽度的80%
+                  : MediaQuery.of(context).size.width > 350 
+                      ? 350  // 限制最大宽度
+                      : MediaQuery.of(context).size.width,
+              child: Column(
+                crossAxisAlignment: CrossAxisAlignment.center,
+                mainAxisAlignment: MainAxisAlignment.center,
+                children: [
+                  if (authState.state == AuthState.authenticated) ...[
+                    if (AppConfig.isOffline) ...[
+                      GestureDetector(
+                        onTap: handleUserCardTap,
+                        child: UserInfoCard(user: authState.user!),
+                      ),
                       const SizedBox(height: 20),
-                    ],
-                    if (AppConfig.isPda) ...[
-                      const PowerConfigButton(),
+                      if (showDictConfig) ...[
+                        const DictConfigButton(),
+                        const SizedBox(height: 20),
+                      ],
+                      if (AppConfig.isPda) ...[
+                        const PowerConfigButton(),
+                        const SizedBox(height: 20),
+                      ],
+                      const ClearCacheButton(),
                       const SizedBox(height: 20),
-                    ],
-                    const ClearCacheButton(),
-                    const SizedBox(height: 20),
-                    const ExportDataButton(),
-                    const SizedBox(height: 20),
-                  ] else ...[
-                    UserInfoCard(user: authState.user!),
-                    const SizedBox(height: 20),
-                    if (AppConfig.isPda) ...[
-                      const PowerConfigButton(),
+                      const ExportDataButton(),
                       const SizedBox(height: 20),
-                      const UploadDataButton(),
+                    ] else ...[
+                      UserInfoCard(user: authState.user!),
+                      const SizedBox(height: 20),
+                      if (AppConfig.isPda) ...[
+                        const PowerConfigButton(),
+                        const SizedBox(height: 20),
+                        const UploadDataButton(),
+                        const SizedBox(height: 20),
+                      ],
+                      const ClearCacheButton(),
+                      const SizedBox(height: 20),
+                      const ConfigButton(),
+                      const SizedBox(height: 20),
+                      // const RfidConfigButton(),
+                      // const SizedBox(height: 20),
+                      // const ScannerLightButton(),
+                      // const SizedBox(height: 20),
+                      const LogoutButton(),
                       const SizedBox(height: 20),
                     ],
-                    const ClearCacheButton(),
-                    const SizedBox(height: 20),
-                    const ConfigButton(),
-                    const SizedBox(height: 20),
-                    // const RfidConfigButton(),
-                    // const SizedBox(height: 20),
-                    // const ScannerLightButton(),
-                    // const SizedBox(height: 20),
-                    const LogoutButton(),
-                    const SizedBox(height: 20),
+                    Text(
+                      _buildVersionText(),
+                      textAlign: TextAlign.center,
+                      style: TextStyle(fontSize: 12, color: Colors.grey),
+                    ),
                   ],
-                  Text(
-                    _buildVersionText(),
-                    textAlign: TextAlign.center,
-                    style: TextStyle(fontSize: 12, color: Colors.grey),
-                  ),
                 ],
-              ],
+              ),
             ),
           ),
         ),
@@ -129,4 +133,4 @@ class ProfilePage extends ConsumerWidget {
 
     return 'ChickenFarm $deviceInfo Powered by IWB ©2025 \nVersion: ${AppConfig.appVersion}';
   }
-}
+}