Forráskód Böngészése

fix: 修改未安装微信隐藏微信入口

Destiny 5 hónapja
szülő
commit
bfddfeb901

+ 9 - 0
lib/dialog/login/login_dialog_controller.dart

@@ -1,8 +1,10 @@
 import 'dart:async';
+import 'dart:ffi';
 import 'dart:io';
 
 import 'package:flutter/cupertino.dart';
 import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
+import 'package:wechat_kit/wechat_kit.dart';
 import 'package:get/get.dart';
 import 'package:injectable/injectable.dart';
 import 'package:keyboard/base/base_controller.dart';
@@ -31,6 +33,8 @@ class LoginDialogController extends BaseController {
   final WechatLoginService wechatLoginService;
   final AccountRepository accountRepository;
 
+  final RxBool isInstallWechat = false.obs;
+
   LoginDialogController(this.wechatLoginService, this.accountRepository);
 
   final RxBool _isAgree = false.obs;
@@ -163,10 +167,15 @@ class LoginDialogController extends BaseController {
   @override
   void onInit() {
     super.onInit();
+    checkIsInstallWechat();
   }
 
   @override
   void onClose() {
     super.onClose();
   }
+
+  void checkIsInstallWechat() async {
+    isInstallWechat.value = await WechatKitPlatform.instance.isInstalled();
+  }
 }

+ 5 - 5
lib/dialog/login/login_dialog_view.dart

@@ -43,11 +43,11 @@ class LoginDialogView extends BaseView<LoginDialogController> {
                     alignment: Alignment.topCenter,
                   ),
                 ),
-                child: Container(
-                  child: Column(
+                child: Obx(() {
+                  return Column(
                     children: [
                       SizedBox(height: 131.h),
-                      _buildWeChatButton(),
+                      controller.isInstallWechat.value ? _buildWeChatButton() : SizedBox(),
                       SizedBox(height: 12.h),
                       _buildAppleButton(),
                       SizedBox(height: 31.h),
@@ -55,8 +55,8 @@ class LoginDialogView extends BaseView<LoginDialogController> {
                       SizedBox(height: 10.h),
                       _buildPrivacy(),
                     ],
-                  ),
-                ),
+                  );
+                }),
               ),
               Positioned(
                   right: 13.w,

+ 8 - 0
lib/module/login/login_controller.dart

@@ -5,6 +5,7 @@ import 'package:keyboard/base/base_controller.dart';
 import 'package:keyboard/dialog/loading_dialog.dart';
 import 'package:keyboard/dialog/login/login_dialog.dart';
 import 'package:sign_in_with_apple/sign_in_with_apple.dart';
+import 'package:wechat_kit/wechat_kit.dart';
 
 import '../../data/consts/error_code.dart';
 import '../../data/consts/event_report.dart';
@@ -40,6 +41,8 @@ class LoginController extends BaseController {
 
   final RxBool _isFirstSend = true.obs;
 
+  final RxBool isInstallWechat = false.obs;
+
   bool get isFirstSend => _isFirstSend.value;
 
   LoginController(this.accountRepository, this.wechatLoginService);
@@ -47,6 +50,7 @@ class LoginController extends BaseController {
   @override
   void onInit() {
     super.onInit();
+    checkIsInstallWechat();
   }
 
   void onPhoneChanged(String value) {
@@ -168,6 +172,10 @@ class LoginController extends BaseController {
     _countDown.value = null;
   }
 
+  void checkIsInstallWechat() async {
+    isInstallWechat.value = await WechatKitPlatform.instance.isInstalled();
+  }
+
   void clickWxLogin() async {
     if (!_isAgree.value) {
       Get.back();

+ 66 - 63
lib/module/login/login_page.dart

@@ -348,79 +348,82 @@ class LoginPage extends BasePage<LoginController> {
             ),
           ),
           SizedBox(height: 18.h),
-          Row(
-            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
-            children: [
-              Column(
-                children: [
-                  Material(
-                    color: Colors.white,
-                    shape: const CircleBorder(),
-                    child: InkWell(
-                      customBorder: const CircleBorder(), // 保证点击区域是圆的
-                      onTap: () {
-                        controller.clickAppleLogin();
-                      },
-                      child: SizedBox(
-                        width: 44.w,
-                        height: 44.w,
-                        child: Center(
-                          child: Assets.images.iconLoginDialogApple.image(
-                            width: 22.w,
-                            height: 22.w,
+          Obx(() {
+            return  Row(
+              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
+              children: [
+                Column(
+                  children: [
+                    Material(
+                      color: Colors.white,
+                      shape: const CircleBorder(),
+                      child: InkWell(
+                        customBorder: const CircleBorder(), // 保证点击区域是圆的
+                        onTap: () {
+                          controller.clickAppleLogin();
+                        },
+                        child: SizedBox(
+                          width: 44.w,
+                          height: 44.w,
+                          child: Center(
+                            child: Assets.images.iconLoginDialogApple.image(
+                              width: 22.w,
+                              height: 22.w,
+                            ),
                           ),
                         ),
                       ),
                     ),
-                  ),
-                  SizedBox(height: 6.w),
-                  Text(
-                    StringName.loginApple,
-                    textAlign: TextAlign.center,
-                    style: TextStyle(
-                      color: Colors.black.withValues(alpha: 0.5),
-                      fontSize: 12.sp,
-                      height: 0,
+                    SizedBox(height: 6.w),
+                    Text(
+                      StringName.loginApple,
+                      textAlign: TextAlign.center,
+                      style: TextStyle(
+                        color: Colors.black.withValues(alpha: 0.5),
+                        fontSize: 12.sp,
+                        height: 0,
+                      ),
                     ),
-                  ),
-                ],
-              ),
-              Column(
-                children: [
-                  Material(
-                    color: Colors.white,
-                    shape: const CircleBorder(),
-                    child: InkWell(
-                      customBorder: const CircleBorder(), // 保证点击区域是圆的
-                      onTap: () {
-                        controller.clickWxLogin();
-                      },
-                      child: SizedBox(
-                        width: 44.w,
-                        height: 44.w,
-                        child: Center(
-                          child: Assets.images.iconWechatLogoBlack.image(
-                            width: 22.w,
-                            height: 22.w,
+                  ],
+                ),
+                controller.isInstallWechat.value ?
+                Column(
+                  children: [
+                    Material(
+                      color: Colors.white,
+                      shape: const CircleBorder(),
+                      child: InkWell(
+                        customBorder: const CircleBorder(), // 保证点击区域是圆的
+                        onTap: () {
+                          controller.clickWxLogin();
+                        },
+                        child: SizedBox(
+                          width: 44.w,
+                          height: 44.w,
+                          child: Center(
+                            child: Assets.images.iconWechatLogoBlack.image(
+                              width: 22.w,
+                              height: 22.w,
+                            ),
                           ),
                         ),
                       ),
                     ),
-                  ),
-                  SizedBox(height: 6.w),
-                  Text(
-                    StringName.wechat,
-                    textAlign: TextAlign.center,
-                    style: TextStyle(
-                      color: Colors.black.withValues(alpha: 0.5),
-                      fontSize: 12.sp,
-                      height: 0,
+                    SizedBox(height: 6.w),
+                    Text(
+                      StringName.wechat,
+                      textAlign: TextAlign.center,
+                      style: TextStyle(
+                        color: Colors.black.withValues(alpha: 0.5),
+                        fontSize: 12.sp,
+                        height: 0,
+                      ),
                     ),
-                  ),
-                ],
-              ),
-            ],
-          ),
+                  ],
+                ) : SizedBox()
+              ],
+            );
+          }),
         ],
       ),
     );

+ 1 - 1
pubspec.yaml

@@ -3,7 +3,7 @@ description: "A new Flutter project."
 
 publish_to: 'none' # Remove this line if you wish to publish to pub.dev
 
-version: 1.1.8+23
+version: 1.1.8+24
 
 environment:
   sdk: ^3.7.0