Commit ec067c1e by tanghuan

更新绑定的手机号

1 parent 4b6090c3
......@@ -10,6 +10,7 @@ import 'package:shared_preferences/shared_preferences.dart';
class AccountPhoneState extends Equatable {
final String phone;
final bool allowBind;
final bool showSnackBar;
final String snackBarMsg;
......@@ -18,6 +19,7 @@ class AccountPhoneState extends Equatable {
const AccountPhoneState({
this.phone = '',
this.allowBind = false,
this.showSnackBar = false,
this.snackBarMsg = '',
this.allowSend = true,
......@@ -26,6 +28,7 @@ class AccountPhoneState extends Equatable {
AccountPhoneState copyWith({
String? phone,
bool? allowBind,
bool? showSnackBar,
String? snackBarMsg,
bool? allowSend,
......@@ -33,6 +36,7 @@ class AccountPhoneState extends Equatable {
}) {
return AccountPhoneState(
phone: phone ?? this.phone,
allowBind: allowBind ?? this.allowBind,
showSnackBar: showSnackBar ?? this.showSnackBar,
snackBarMsg: snackBarMsg ?? this.snackBarMsg,
allowSend: allowSend ?? this.allowSend,
......@@ -43,6 +47,7 @@ class AccountPhoneState extends Equatable {
@override
List<Object?> get props => [
phone,
allowBind,
showSnackBar,
snackBarMsg,
allowSend,
......@@ -72,6 +77,10 @@ class AccountPhoneCubit extends Cubit<AccountPhoneState> {
_phoneAuthRepository = getIt.get<PhoneAuthRepository>();
}
void change(){
emit(state.copyWith(allowBind: true));
}
/// 开始倒计时
void startCountdown() {
countdown = 60;
......
......@@ -63,7 +63,9 @@ class AccountPage extends StatelessWidget {
leading: Icon(Icons.mobile_friendly),
title: Text('手机号绑定'),
subtitle: Text(
state.phone != '' ? '${state.phone.substring(0, 3)}****${state.phone.substring(7, 11)}' : '未绑定',
state.phone != ''
? '${state.phone.substring(0, 3)}****${state.phone.substring(7, 11)}'
: '未绑定',
style: TextStyle(
fontSize: 14.0,
color: Colors.grey,
......@@ -86,7 +88,7 @@ class AccountPage extends StatelessWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircularProgressIndicator(),
CircularProgressIndicator(color: Color(0xFF7691FA)),
SizedBox(height: 16),
Text('加载中...'),
],
......
......@@ -27,7 +27,7 @@ class AccountPhonePage extends StatelessWidget {
color: Colors.white, // 设置返回图标按钮的颜色
),
),
body: state.phone != ''
body: (state.phone != '' && !state.allowBind)
? Center(
child: Column(children: [
SizedBox(height: 120),
......@@ -39,6 +39,35 @@ class AccountPhonePage extends StatelessWidget {
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 100),
Padding(
padding: EdgeInsets.all(80),
child: SizedBox(
width: double.infinity,
height: 47,
child: ElevatedButton(
onPressed: () {
context.read<AccountPhoneCubit>().change();
},
style: ElevatedButton.styleFrom(
backgroundColor: Color(0xFF7691FA),
foregroundColor: Colors.white,
textStyle: TextStyle(fontSize: 19),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(23.5),
),
),
child: Text(
'更换绑定手机号',
style: TextStyle(
fontSize: 19,
fontWeight: FontWeight.w400,
color: Color(0xFFFFFFFF),
),
strutStyle: StrutStyle(height: 22 / 19),
),
),
)),
]),
)
: Padding(
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!