Commit b9526f1e by tanghuan

首次打开时,显示个人信息收集提示

1 parent a56a4bd5
......@@ -19,6 +19,7 @@ class LoginMainState extends Equatable {
final String appleUserIdentifier;
final bool loading;
final bool wechatInstalled;
final bool showPrivacyFirstTime;
const LoginMainState({
this.agreed = false,
......@@ -28,6 +29,7 @@ class LoginMainState extends Equatable {
this.appleUserIdentifier = '',
this.loading = false,
this.wechatInstalled = false,
this.showPrivacyFirstTime = false,
});
LoginMainState copyWith({
......@@ -38,6 +40,7 @@ class LoginMainState extends Equatable {
String? appleUserIdentifier,
bool? loading,
bool? wechatInstalled,
bool? showPrivacyFirstTime,
}) {
return LoginMainState(
agreed: agreed ?? this.agreed,
......@@ -47,6 +50,7 @@ class LoginMainState extends Equatable {
appleUserIdentifier: appleUserIdentifier ?? this.appleUserIdentifier,
loading: loading ?? this.loading,
wechatInstalled: wechatInstalled ?? this.wechatInstalled,
showPrivacyFirstTime: showPrivacyFirstTime ?? this.showPrivacyFirstTime,
);
}
......@@ -59,6 +63,7 @@ class LoginMainState extends Equatable {
appleUserIdentifier,
loading,
wechatInstalled,
showPrivacyFirstTime,
];
}
......@@ -79,6 +84,25 @@ class LoginMainCubit extends Cubit<LoginMainState> {
_fluwxCancelable = _fluwx.addSubscriber(_responseListener);
_wechatAuthRepository = getIt.get<WechatAuthRepository>();
_userAuthRepository = getIt.get<UserAuthRepository>();
// 检查是否首次打开登录页面,显示个人信息收集提示
_checkFirstTimePrivacy();
}
// 检查是否首次打开,显示个人信息收集提示
void _checkFirstTimePrivacy() async {
var sharedPreferences = getIt.get<SharedPreferences>();
var hasShownPrivacy = sharedPreferences.getBool(Constant.hasShownPrivacyFirstTimeKey) ?? false;
if (!hasShownPrivacy) {
emit(state.copyWith(showPrivacyFirstTime: true));
}
}
// 确认已显示个人信息收集提示
void confirmPrivacyFirstTime() async {
var sharedPreferences = getIt.get<SharedPreferences>();
await sharedPreferences.setBool(Constant.hasShownPrivacyFirstTimeKey, true);
emit(state.copyWith(showPrivacyFirstTime: false));
}
void toggleAgreed(bool value) {
......
......@@ -109,6 +109,12 @@ class Constant {
///
static const String classIdSetKey = 'auth_class_ids';
/// 隐私政策相关
/// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///
/// 首次打开登录页面时,是否已显示个人信息收集提示
static const String hasShownPrivacyFirstTimeKey = 'has_shown_privacy_first_time';
/// 测试阶段使用
static const bool needIM = true;
static const bool needUpgrade = true;
......
......@@ -162,6 +162,8 @@ class LoginMainPage extends StatelessWidget {
_showAgreementDialog(context, context.read<LoginMainCubit>());
} else if (state.showNeedWechatForApple) {
_showNeedWechatDialogForApple(context, context.read<LoginMainCubit>());
} else if (state.showPrivacyFirstTime) {
_showPrivacyFirstTimeDialog(context, context.read<LoginMainCubit>());
}
},
),
......@@ -236,7 +238,7 @@ class LoginMainPage extends StatelessWidget {
style: TextStyle(color: Color(0xFF666666), fontSize: 14),
),
TextSpan(
text: '《班小二数据安全和隐私政策》',
text: '《班小二数据安全和隐私政策》',
style: TextStyle(color: Color(0xFF7691FA), fontSize: 14),
recognizer: TapGestureRecognizer()
..onTap = () {
......@@ -262,7 +264,7 @@ class LoginMainPage extends StatelessWidget {
},
),
TextSpan(
text: '。如您同意上述文件的全部内容,请点击“同意”以继续。',
text: '。如您同意上述文件的全部内容,请点击"同意"以继续。',
style: TextStyle(color: Color(0xFF666666), fontSize: 14),
),
],
......@@ -432,4 +434,111 @@ class LoginMainPage extends StatelessWidget {
},
);
}
// 首次打开显示个人信息收集提示弹窗
Future<void> _showPrivacyFirstTimeDialog(BuildContext context, LoginMainCubit loginMainCubit) async {
await showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(5),
),
),
title: Text(
'重要提示',
style: TextStyle(
fontSize: 17,
color: Color(0xFF000000),
),
textAlign: TextAlign.center,
),
content: SingleChildScrollView(
child: Text.rich(
TextSpan(
children: [
TextSpan(
text: '尊敬的用户,欢迎使用班小二APP!\n\n',
style: TextStyle(color: Color(0xFF666666), fontSize: 14),
),
// TextSpan(
// text: '为了向您提供更好的服务,我们需要收集以下个人信息:\n\n',
// style: TextStyle(color: Color(0xFF666666), fontSize: 14),
// ),
// TextSpan(
// text: '• 收集目的:用于用户身份识别、登录验证、提供教育相关服务\n',
// style: TextStyle(color: Color(0xFF666666), fontSize: 14),
// ),
// TextSpan(
// text: '• 收集方式:通过微信授权、手机号验证等方式获取\n',
// style: TextStyle(color: Color(0xFF666666), fontSize: 14),
// ),
// TextSpan(
// text: '• 信息范围:包括您的微信昵称、头像、手机号、学生信息等\n\n',
// style: TextStyle(color: Color(0xFF666666), fontSize: 14),
// ),
TextSpan(
text: '我们将严格遵守',
style: TextStyle(color: Color(0xFF666666), fontSize: 14),
),
TextSpan(
text: '《班小二数据安全和隐私政策》',
style: TextStyle(color: Color(0xFF7691FA), fontSize: 14),
recognizer: TapGestureRecognizer()
..onTap = () {
router.push(
'/link',
extra: {'url': 'https://bxr.banxiaoer.net/apps/privacysettings.html', 'title': '隐私保障'},
);
},
),
TextSpan(
text: '与',
style: TextStyle(color: Color(0xFF666666), fontSize: 14),
),
TextSpan(
text: '《用户协议》',
style: TextStyle(color: Color(0xFF7691FA), fontSize: 14),
recognizer: TapGestureRecognizer()
..onTap = () {
router.push(
'/link',
extra: {'url': 'https://bxr.banxiaoer.net/apps/useragreement.html', 'title': '用户协议'},
);
},
),
TextSpan(
text: '保护您的个人信息安全。',
style: TextStyle(color: Color(0xFF666666), fontSize: 14),
),
],
),
),
),
actions: [
Center(
child: TextButton(
onPressed: () {
Navigator.of(context).pop();
loginMainCubit.confirmPrivacyFirstTime();
},
style: TextButton.styleFrom(
foregroundColor: Color(0xFF7691FA),
textStyle: TextStyle(fontSize: 17),
minimumSize: Size.fromHeight(40),
padding: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.zero,
),
),
child: Text('我知道了'),
),
),
],
);
},
);
}
}
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!