fluttercandies / flutter_ali_auth

Flutter Ali Auth Plugin 阿里云一键登录Flutter插件
https://pub.flutter-io.cn/packages/flutter_ali_auth
MIT License
49 stars 16 forks source link

怎样配置点击其他登录方式前提醒先同意用户协议(在不关闭一键登录页的前提下) #32

Open toknT opened 11 months ago

toknT commented 11 months ago

Platforms

Android

Description

全屏模式,点击其他登录方式前,先提醒同意用户协议.

My code

Future<void> _aliSmsOnEvent(AuthResponseModel responseModel) async {
    final AuthResultCode resultCode = AuthResultCode.fromCode(
      responseModel.resultCode!,
    );
    switch (resultCode) {
      case AuthResultCode.success:
        if (responseModel.token != null && responseModel.token!.isNotEmpty) {
          String aliAuthToken = responseModel.token ?? '';
          if (aliAuthToken != '') {
            _loginViaPhone(aliAuthToken);
          } else {
            showToast(context: context, message: '登录出错');
          }
        }
        break;
      case AuthResultCode.envCheckSuccess:
        setState(() {
          _isSupportAliSimLogin = true;
        });
        break;
      case AuthResultCode.onCustomViewTap:
        print(responseModel.msg);
        if (_hasCheckAgreement == false) {
          showToast(context: context, message: '先同意用户协议');
          return;
        }
        switch (responseModel.msg) {
          case '2':
            _loginViaWechat();
            break;
          case '3':
            _loginViaApple();
            break;
          case '4':
            _loginViaSmsCode();
            break;
        }
        break;
      case AuthResultCode.loginControllerClickCheckBoxBtn:
        _hasCheckAgreement = !_hasCheckAgreement;
        break;
      default:
        print('ali sim auth event:');
        print(responseModel.innerCode);
        print(responseModel.toString());
        break;
    }
  }

  bool _hasCheckAgreement = false;

Try do it

目前在onCustomViewTap判断_hasCheckAgreement是否同意的但全屏登录页还是会被自动关闭