Skip to content

Commit 0c2a5cf

Browse files
author
tangyueyang
committed
Mod 退出逻辑优化
1 parent a4ad325 commit 0c2a5cf

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

lib/main.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@ import 'package:flutter/cupertino.dart';
22
import 'package:flutter/material.dart';
33
import 'package:fluttertoast/fluttertoast.dart';
44
import 'package:leancloud_storage/leancloud.dart';
5+
import 'package:learn_flutter/leancloud_config.dart';
56
import 'package:learn_flutter/pages/home/index.dart';
67
import 'package:learn_flutter/pages/item_info/index.dart';
78
import 'package:learn_flutter/pages/login/login.dart';
89
import 'package:learn_flutter/pages/mine/index.dart';
910
import 'package:learn_flutter/pages/movie/movie.dart';
11+
import 'package:learn_flutter/pages/settings/settings.dart';
1012
import 'package:learn_flutter/pages/webview_page/index.dart';
1113

1214
void main() {
1315
initLeancloud();
1416
return runApp(MyApp());
1517
}
1618

19+
/// 初始化LeanCloud
1720
initLeancloud() {
18-
LeanCloud.initialize();
21+
LeanCloud.initialize(LeanCloudConfig.APP_ID, LeanCloudConfig.APP_KEY, server: LeanCloudConfig.SERVER);
1922
}
2023

2124
class MyApp extends StatelessWidget {
@@ -25,6 +28,7 @@ class MyApp extends StatelessWidget {
2528
'/movie': (context, settings) => Movie(),
2629
'/mine': (context, settings) => Mine(),
2730
'/item_info': (context, settings) => ItemInfo(),
31+
'/settings': (context, settings) => Settings(),
2832
'/webview': (context, settings) =>
2933
WebViewPage(url: (settings.arguments as Map<String, String>)['url'])
3034
};

lib/pages/login/login.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class LoginState extends State<Login> {
2323
iconTheme: IconThemeData(color: Colors.black54),
2424
leading: GestureDetector(
2525
child: Icon(Icons.close),
26+
onTap: () {
27+
Navigator.of(context).pushNamedAndRemoveUntil('/', (route) => false);
28+
},
2629
),
2730
actions: <Widget>[
2831
Container(

lib/pages/settings/settings.dart

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import 'package:flutter/material.dart';
2+
3+
class Settings extends StatelessWidget {
4+
@override
5+
Widget build(BuildContext context) {
6+
return Scaffold(
7+
backgroundColor: Color(0xFFF6F6F6),
8+
appBar: AppBar(
9+
title: Text('账户设置', style: TextStyle(color: Colors.black)),
10+
centerTitle: true,
11+
iconTheme: IconThemeData(color: Colors.black),
12+
backgroundColor: Colors.white,
13+
elevation: 0,
14+
),
15+
body: Column(children: <Widget>[
16+
GestureDetector(
17+
child: Container(
18+
width: double.infinity,
19+
color: Colors.white,
20+
margin: EdgeInsets.only(top: 10),
21+
child: FlatButton(
22+
onPressed: null,
23+
child: Text(
24+
'退出登录',
25+
style: TextStyle(
26+
color: Colors.black,
27+
fontSize: 14,
28+
fontWeight: FontWeight.bold,
29+
),
30+
),
31+
),
32+
),
33+
onTap: () {
34+
Navigator.of(context).pushNamedAndRemoveUntil('/login', (route) => false);
35+
},
36+
),
37+
]),
38+
);
39+
}
40+
}

0 commit comments

Comments
 (0)