You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
354 lines
10 KiB
354 lines
10 KiB
import 'package:flutter/material.dart'; |
|
import 'package:huixiang/generated/l10n.dart'; |
|
import 'package:huixiang/login/login_page.dart'; |
|
import 'package:huixiang/main.dart'; |
|
import 'package:huixiang/utils/event_type.dart'; |
|
import 'package:huixiang/view_widget/language_set_page.dart'; |
|
import 'package:huixiang/view_widget/round_button.dart'; |
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
class SettingPage extends StatefulWidget { |
|
@override |
|
State<StatefulWidget> createState() { |
|
return _SettingPage(); |
|
} |
|
} |
|
|
|
class _SettingPage extends State<SettingPage> { |
|
String locale = "tw"; |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
return Scaffold( |
|
appBar: AppBar( |
|
title: Text( |
|
S.of(context).shezhi, |
|
style: TextStyle( |
|
color: Colors.black, |
|
fontWeight: FontWeight.bold, |
|
), |
|
), |
|
centerTitle: false, |
|
backgroundColor: Color(0xFFF7F7F7), |
|
elevation: 0, |
|
leading: GestureDetector( |
|
onTap: () { |
|
Navigator.of(context).pop(); |
|
}, |
|
child: Container( |
|
alignment: Alignment.centerRight, |
|
margin: EdgeInsets.only(left: 10), |
|
padding: EdgeInsets.all(6), |
|
child: Icon( |
|
Icons.arrow_back_ios, |
|
color: Colors.black, |
|
size: 24, |
|
), |
|
), |
|
), |
|
titleSpacing: 2, |
|
leadingWidth: 56, |
|
), |
|
body: Container( |
|
decoration: new BoxDecoration( |
|
border: |
|
Border(bottom: BorderSide(color: Color(0xffF7F7F7), width: 0.0)), |
|
color: Color(0xffF7F7F7), |
|
), |
|
child: Column( |
|
mainAxisAlignment: MainAxisAlignment.start, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
mainAxisSize: MainAxisSize.max, |
|
children: [ |
|
SizedBox( |
|
height: 24, |
|
), |
|
Container( |
|
margin: EdgeInsets.only(left: 16), |
|
child: Text( |
|
S.of(context).shezhi, |
|
style: TextStyle( |
|
fontWeight: FontWeight.bold, |
|
color: Color(0xFF353535), |
|
fontSize: 16, |
|
), |
|
), |
|
), |
|
SizedBox( |
|
height: 16, |
|
), |
|
GestureDetector( |
|
onTap: () { |
|
showModalBottomSheet( |
|
backgroundColor: Colors.transparent, |
|
context: context, |
|
builder: (context) { |
|
return LanguageSetPage(locale); |
|
}).then((value) => { |
|
setState(() { |
|
if (value == "tw") { |
|
S.load(Locale.fromSubtags( |
|
languageCode: 'zh', countryCode: 'TW')); |
|
locale = "tw"; |
|
} else { |
|
// 语言 語言 |
|
S.load(Locale.fromSubtags( |
|
languageCode: 'zh', countryCode: 'CN')); |
|
locale = "zh"; |
|
} |
|
eventBus.fire(EventType(1)); |
|
setState(() {}); |
|
}) |
|
}); |
|
}, |
|
child: settingItem( |
|
S.of(context).yuyan, |
|
locale == "zh" |
|
? S.of(context).zhongwenjianti |
|
: S.of(context).fantizhongwen), |
|
), |
|
GestureDetector( |
|
child: |
|
settingItem(S.of(context).quanxian, S.of(context).weikaiqi), |
|
onTap: () { |
|
Navigator.of(context).pushNamed('/router/permission_setting'); |
|
}, |
|
), |
|
GestureDetector( |
|
child: settingSingleItem(S.of(context).bangzhuyufankui), |
|
onTap: () { |
|
Navigator.of(context).pushNamed('/router/help_feedback_page'); |
|
}, |
|
), |
|
GestureDetector( |
|
child: settingSingleItem(S.of(context).guanyu), |
|
onTap: () { |
|
Navigator.of(context).pushNamed('/router/about_page'); |
|
}, |
|
), |
|
Expanded( |
|
child: Column( |
|
mainAxisAlignment: MainAxisAlignment.end, |
|
mainAxisSize: MainAxisSize.max, |
|
children: [ |
|
InkWell( |
|
onTap: () { |
|
logOut(); |
|
}, |
|
child: Container( |
|
height: 54, |
|
alignment: Alignment.center, |
|
color: Color(0xFF32A060), |
|
child: RoundButton( |
|
text: S.of(context).tuichudenglu, |
|
backgroup: Color(0xFF32A060), |
|
textColor: Colors.white, |
|
fontSize: 16, |
|
fontWeight: FontWeight.bold, |
|
), |
|
), |
|
), |
|
], |
|
), |
|
flex: 1, |
|
) |
|
], |
|
), |
|
), |
|
); |
|
} |
|
|
|
logOut() async { |
|
SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); |
|
sharedPreferences.clear(); |
|
// Navigator.of(context).popUntil(ModalRoute.withName('/router/login')); |
|
|
|
Navigator.pushAndRemoveUntil(context, new MaterialPageRoute( |
|
builder: (BuildContext context) { |
|
return LoginPage(); |
|
}, |
|
), (route) => route == null); |
|
} |
|
|
|
Widget settingItem(left, right) { |
|
return Container( |
|
margin: EdgeInsets.fromLTRB(16, 8, 16, 8), |
|
padding: EdgeInsets.fromLTRB(20, 16, 20, 16), |
|
decoration: BoxDecoration( |
|
color: Colors.white, |
|
borderRadius: BorderRadius.all(Radius.circular(8)), |
|
boxShadow: [ |
|
BoxShadow( |
|
color: Colors.black.withAlpha(12), |
|
offset: Offset(0, 3), |
|
blurRadius: 14, |
|
spreadRadius: 0, |
|
) |
|
]), |
|
child: Row( |
|
children: [ |
|
Expanded( |
|
child: Text( |
|
left, |
|
style: TextStyle( |
|
fontWeight: FontWeight.bold, |
|
fontSize: 14, |
|
color: Color(0xFF353535), |
|
), |
|
), |
|
flex: 1, |
|
), |
|
Text( |
|
right, |
|
style: TextStyle(fontSize: 12, color: Color(0xFF727272)), |
|
), |
|
SizedBox( |
|
width: 16, |
|
), |
|
Icon( |
|
Icons.keyboard_arrow_right, |
|
size: 20, |
|
), |
|
], |
|
), |
|
); |
|
} |
|
|
|
Widget settingSingleItem(right) { |
|
return Container( |
|
margin: EdgeInsets.fromLTRB(16, 8, 16, 8), |
|
padding: EdgeInsets.fromLTRB(20, 16, 20, 16), |
|
decoration: BoxDecoration( |
|
color: Colors.white, |
|
borderRadius: BorderRadius.all(Radius.circular(8)), |
|
boxShadow: [ |
|
BoxShadow( |
|
color: Colors.black.withAlpha(12), |
|
offset: Offset(0, 3), |
|
blurRadius: 14, |
|
spreadRadius: 0, |
|
) |
|
], |
|
), |
|
child: Row( |
|
children: [ |
|
Expanded( |
|
child: Text( |
|
right, |
|
style: TextStyle( |
|
fontSize: 14, |
|
color: Color(0xFF353535), |
|
fontWeight: FontWeight.bold, |
|
), |
|
), |
|
), |
|
SizedBox( |
|
width: 16, |
|
), |
|
Icon( |
|
Icons.keyboard_arrow_right, |
|
size: 20, |
|
), |
|
], |
|
), |
|
); |
|
} |
|
|
|
List<String> title = [ |
|
S.current.dingwei, |
|
S.current.tongzhi, |
|
S.current.xiangji, |
|
"Face ID", |
|
]; |
|
List<String> icons = [ |
|
"assets/image/icon_permission_location.png", |
|
"assets/image/icon_permission_notices.png", |
|
"assets/image/icon_permission_camera.png", |
|
"assets/image/icon_permission_face_id.png", |
|
]; |
|
List<String> contents = [ |
|
S.current.weizhitishixinxi, |
|
S.current.tongzhitishixinxi, |
|
S.current.xiangjitishixinxi, |
|
S.current.faceidtishixinxi, |
|
]; |
|
|
|
Widget buildPermissionItem(title, icon, content) { |
|
return Container( |
|
margin: EdgeInsets.fromLTRB(16, 8, 16, 8), |
|
padding: EdgeInsets.fromLTRB(20, 16, 20, 16), |
|
decoration: BoxDecoration( |
|
color: Colors.white, |
|
borderRadius: BorderRadius.all(Radius.circular(8)), |
|
boxShadow: [ |
|
BoxShadow( |
|
color: Colors.black.withAlpha(12), |
|
offset: Offset(0, 3), |
|
blurRadius: 14, |
|
spreadRadius: 0) |
|
]), |
|
child: Row( |
|
mainAxisAlignment: MainAxisAlignment.center, |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
children: [ |
|
Expanded( |
|
child: Column( |
|
children: [ |
|
Row( |
|
children: [ |
|
Text( |
|
title, |
|
style: TextStyle( |
|
color: Colors.black, |
|
fontSize: 16, |
|
fontWeight: FontWeight.bold), |
|
), |
|
SizedBox( |
|
width: 8, |
|
), |
|
Image.asset( |
|
icon, |
|
width: 22, |
|
height: 22, |
|
) |
|
], |
|
), |
|
SizedBox( |
|
height: 8, |
|
), |
|
Text( |
|
content, |
|
overflow: TextOverflow.ellipsis, |
|
maxLines: 2, |
|
style: TextStyle( |
|
color: Color(0xFF353535), |
|
fontSize: 12, |
|
), |
|
), |
|
], |
|
), |
|
), |
|
SizedBox( |
|
width: 32, |
|
), |
|
Row( |
|
children: [ |
|
Text( |
|
S.of(context).weikaiqi, |
|
style: TextStyle( |
|
color: Color(0xFF32A060), |
|
fontSize: 12, |
|
), |
|
), |
|
Icon( |
|
Icons.keyboard_arrow_right, |
|
size: 16, |
|
color: Color(0xFF32A060), |
|
) |
|
], |
|
), |
|
], |
|
), |
|
); |
|
} |
|
}
|
|
|