소스 검색

[mob] Use SegmentedButton instead of broken(UI) toggle in app store subscription page

ashilkn 1 년 전
부모
커밋
d35fe3ff00
1개의 변경된 파일21개의 추가작업 그리고 25개의 파일을 삭제
  1. 21 25
      mobile/lib/ui/payment/store_subscription_page.dart

+ 21 - 25
mobile/lib/ui/payment/store_subscription_page.dart

@@ -385,21 +385,6 @@ class _StoreSubscriptionPageState extends State<StoreSubscriptionPage> {
   }
   }
 
 
   Widget _showSubscriptionToggle() {
   Widget _showSubscriptionToggle() {
-    Widget planText(String title, bool reduceOpacity) {
-      return Padding(
-        padding: const EdgeInsets.only(left: 4, right: 4),
-        child: Text(
-          title,
-          style: TextStyle(
-            color: Theme.of(context)
-                .colorScheme
-                .onSurface
-                .withOpacity(reduceOpacity ? 0.5 : 1.0),
-          ),
-        ),
-      );
-    }
-
     return Container(
     return Container(
       padding: const EdgeInsets.only(left: 8, right: 8, top: 2, bottom: 2),
       padding: const EdgeInsets.only(left: 8, right: 8, top: 2, bottom: 2),
       margin: const EdgeInsets.only(bottom: 6),
       margin: const EdgeInsets.only(bottom: 6),
@@ -409,18 +394,29 @@ class _StoreSubscriptionPageState extends State<StoreSubscriptionPage> {
             child: Row(
             child: Row(
               mainAxisAlignment: MainAxisAlignment.center,
               mainAxisAlignment: MainAxisAlignment.center,
               children: [
               children: [
-                planText(S.of(context).monthly, showYearlyPlan),
-                Switch(
-                  value: showYearlyPlan,
-                  activeColor: Colors.white,
-                  inactiveThumbColor: Colors.white,
-                  activeTrackColor: getEnteColorScheme(context).strokeMuted,
-                  onChanged: (value) async {
-                    showYearlyPlan = value;
-                    await _filterStorePlansForUi();
+                SegmentedButton(
+                  style: SegmentedButton.styleFrom(
+                    selectedBackgroundColor:
+                        getEnteColorScheme(context).fillMuted,
+                    selectedForegroundColor:
+                        getEnteColorScheme(context).textBase,
+                  ),
+                  segments: <ButtonSegment<bool>>[
+                    ButtonSegment(
+                      label: Text(S.of(context).monthly),
+                      value: false,
+                    ),
+                    ButtonSegment(
+                      label: Text(S.of(context).yearly),
+                      value: true,
+                    ),
+                  ],
+                  selected: {showYearlyPlan},
+                  onSelectionChanged: (p0) {
+                    showYearlyPlan = p0.first;
+                    _filterStorePlansForUi();
                   },
                   },
                 ),
                 ),
-                planText(S.of(context).yearly, !showYearlyPlan),
               ],
               ],
             ),
             ),
           ),
           ),