Bläddra i källkod

[new]优化首页优惠卷布局

zk 4 månader sedan
förälder
incheckning
2d240cf6d1
1 ändrade filer med 69 tillägg och 59 borttagningar
  1. 69 59
      lib/module/main/main_page.dart

+ 69 - 59
lib/module/main/main_page.dart

@@ -80,7 +80,18 @@ class MainPage extends BasePage<MainController> {
   }
 
   Widget buildMainBottomView() {
+    return Obx(() {
+      if (controller.lastSelectedGoods == null) {
+        return buildSlidingSheet(false);
+      } else {
+        return buildSlidingSheet(true);
+      }
+    });
+  }
+
+  SlidingSheet buildSlidingSheet(bool isShowActivity) {
     return SlidingSheet(
+      key: Key(isShowActivity ? 'activity_view' : 'not_activity_view'),
       color: ColorName.transparent,
       snapSpec: SnapSpec(
         initialSnap: SnapSpec.headerSnap,
@@ -92,7 +103,9 @@ class MainPage extends BasePage<MainController> {
         // the total available space that the sheet can expand to.
         positioning: SnapPositioning.relativeToAvailableSpace,
       ),
-      headerBuilder: buildHeaderBuilder,
+      headerBuilder: (BuildContext context, SheetState state) {
+        return buildHeaderView(isShowActivity);
+      },
       builder: buildTrackEntranceBuilder,
     );
   }
@@ -478,65 +491,62 @@ class MainPage extends BasePage<MainController> {
   }
 
   Widget buildHeaderBuilder(BuildContext context, SheetState state) {
-    return Obx(() {
-      return IntrinsicHeight(
-        child: Stack(
-          alignment: Alignment.topCenter,
-          children: [
-            Visibility(
-              visible: controller.lastSelectedGoods != null,
-              child: Assets.images.bgMemberActivityMain
-                  .image(width: 336.w, height: 67.w),
-            ),
-            Visibility(
-                visible: controller.lastSelectedGoods != null,
-                child: buildActivityMemberView()),
-            Column(
-              children: [
-                // Visibility(
-                //     visible: controller.lastSelectedGoods != null,
-                //     child: SizedBox(height: 58.w)),
-                SizedBox(height: 58.w),
-                Container(
-                  width: double.infinity,
-                  decoration: BoxDecoration(
-                    color: '#F9F9F9'.color,
-                    borderRadius: BorderRadius.only(
-                      topLeft: Radius.circular(20.w),
-                      topRight: Radius.circular(20.w),
-                    ),
-                    boxShadow: [
-                      BoxShadow(
-                        color: ColorName.black.withOpacity(0.01),
-                        blurRadius: 10,
-                        offset:
-                            const Offset(0, -2), // changes position of shadow
-                      ),
-                    ],
-                  ),
-                  child: Column(
-                    children: [
-                      SizedBox(height: 5.w),
-                      Container(
-                        width: 32.w,
-                        height: 3.w,
-                        decoration: BoxDecoration(
-                            color: '#D9D9D9'.color,
-                            borderRadius:
-                                BorderRadius.all(Radius.circular(49.w))),
-                      ),
-                      SizedBox(height: 12.w),
-                      buildSelectFriendInfoView(),
-                      SizedBox(height: 13.w)
-                    ],
+    return buildHeaderView(false);
+  }
+
+  Widget buildHeaderView(bool isShowActivity) {
+    return IntrinsicHeight(
+      child: Stack(
+        alignment: Alignment.topCenter,
+        children: [
+          Visibility(
+            visible: isShowActivity,
+            child: Assets.images.bgMemberActivityMain
+                .image(width: 336.w, height: 67.w),
+          ),
+          Visibility(visible: isShowActivity, child: buildActivityMemberView()),
+          Column(
+            children: [
+              Visibility(
+                  visible: isShowActivity, child: SizedBox(height: 58.w)),
+              Container(
+                width: double.infinity,
+                decoration: BoxDecoration(
+                  color: '#F9F9F9'.color,
+                  borderRadius: BorderRadius.only(
+                    topLeft: Radius.circular(20.w),
+                    topRight: Radius.circular(20.w),
                   ),
-                )
-              ],
-            )
-          ],
-        ),
-      );
-    });
+                  boxShadow: [
+                    BoxShadow(
+                      color: ColorName.black.withOpacity(0.01),
+                      blurRadius: 10,
+                      offset: const Offset(0, -2), // changes position of shadow
+                    ),
+                  ],
+                ),
+                child: Column(
+                  children: [
+                    SizedBox(height: 5.w),
+                    Container(
+                      width: 32.w,
+                      height: 3.w,
+                      decoration: BoxDecoration(
+                          color: '#D9D9D9'.color,
+                          borderRadius:
+                              BorderRadius.all(Radius.circular(49.w))),
+                    ),
+                    SizedBox(height: 12.w),
+                    buildSelectFriendInfoView(),
+                    SizedBox(height: 13.w)
+                  ],
+                ),
+              )
+            ],
+          )
+        ],
+      ),
+    );
   }
 
   Widget buildActivityMemberView() {