Commit ec067c1e by tanghuan

更新绑定的手机号

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