mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-05-17 12:55:57 +08:00
feature:个人设置
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
class Api{
|
||||
static const String BASE_URL = 'http://flutter-go.alibaba.net/';
|
||||
// static const String BASE_URL = 'http://flutter-go.alibaba.net/';
|
||||
static const String BASE_URL = 'https://flutter-go.pub/api/';
|
||||
|
||||
static const String DO_LOGIN = BASE_URL+'doLogin';//登陆
|
||||
|
||||
@ -9,7 +10,6 @@ class Api{
|
||||
|
||||
static const String GET_USER_INFO = BASE_URL+'getUserInfo';//获取用户信息
|
||||
|
||||
static const String RedirectIp = 'http://100.81.211.172/';
|
||||
|
||||
static const String VERSION = BASE_URL+'getAppVersion';//检查版本
|
||||
|
||||
@ -24,4 +24,8 @@ class Api{
|
||||
static const String ADD_COLLECTION = BASE_URL+'auth/addCollection';//添加收藏
|
||||
|
||||
static const String CHECK_COLLECTED = BASE_URL+'auth/checkCollected';//校验收藏
|
||||
|
||||
static const String SET_THEMECOLOR = BASE_URL+'auth/setThemeColor';//设置主题颜色
|
||||
|
||||
static const String GET_THEMECOLOR = BASE_URL +'/getThemeColor';//获取主题颜色
|
||||
}
|
47
lib/components/single_theme_color.dart
Normal file
47
lib/components/single_theme_color.dart
Normal file
@ -0,0 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_go/event/event_bus.dart';
|
||||
import 'package:flutter_go/event/event_model.dart';
|
||||
// import 'package:event_bus/event_bus.dart';
|
||||
|
||||
class SingleThemeColor extends StatelessWidget {
|
||||
final int themeColor;
|
||||
final String coloeName;
|
||||
|
||||
const SingleThemeColor({Key key, this.themeColor, this.coloeName})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: (){
|
||||
if(ApplicationEvent.event != null){
|
||||
print('fire ${this.themeColor}');
|
||||
ApplicationEvent.event.fire(UserSettingThemeColorEvent(this.themeColor));
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
margin: const EdgeInsets.all(5.0),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(50),
|
||||
),
|
||||
color: Color(this.themeColor),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
this.coloeName,
|
||||
style: TextStyle(
|
||||
color: Color(this.themeColor),
|
||||
fontSize: 14.0,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -11,4 +11,9 @@ class UserGithubOAuthEvent{
|
||||
final String token;
|
||||
final bool isSuccess;
|
||||
UserGithubOAuthEvent(this.loginName,this.token,this.isSuccess);
|
||||
}
|
||||
|
||||
class UserSettingThemeColorEvent{
|
||||
final int settingThemeColor;
|
||||
UserSettingThemeColorEvent(this.settingThemeColor);
|
||||
}
|
@ -13,10 +13,12 @@ import 'package:flutter_go/views/login_page/login_page.dart';
|
||||
import 'package:flutter_go/utils/data_utils.dart';
|
||||
import 'package:flutter_go/model/user_info.dart';
|
||||
import 'package:flutter_jpush/flutter_jpush.dart';
|
||||
import 'package:flutter_go/event/event_bus.dart';
|
||||
import 'package:flutter_go/event/event_model.dart';
|
||||
import 'package:event_bus/event_bus.dart';
|
||||
|
||||
//import 'views/welcome_page/index.dart';
|
||||
|
||||
const int ThemeColor = 0xFFC91B3A;
|
||||
SpUtil sp;
|
||||
var db;
|
||||
|
||||
@ -40,6 +42,12 @@ class _MyAppState extends State<MyApp> {
|
||||
bool isConnected = false;
|
||||
String registrationId;
|
||||
List notificationList = [];
|
||||
int themeColor = 0xFFC91B3A;
|
||||
|
||||
_MyAppState() {
|
||||
final eventBus = new EventBus();
|
||||
ApplicationEvent.event = eventBus;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -53,18 +61,23 @@ class _MyAppState extends State<MyApp> {
|
||||
this.isConnected = connected;
|
||||
if (connected) {
|
||||
//在启动的时候会去连接自己的服务器,连接并注册成功之后会返回一个唯一的设备号
|
||||
FlutterJPush.getRegistrationID().then((String regId) {
|
||||
print("主动获取设备号:$regId");
|
||||
setState(() {
|
||||
this.registrationId = regId;
|
||||
try {
|
||||
FlutterJPush.getRegistrationID().then((String regId) {
|
||||
print("主动获取设备号:$regId");
|
||||
setState(() {
|
||||
this.registrationId = regId;
|
||||
});
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
print('主动获取设备号Error:$error');
|
||||
}
|
||||
;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
FlutterJPush
|
||||
.addReceiveNotificationListener((JPushNotification notification) {
|
||||
FlutterJPush.addReceiveNotificationListener(
|
||||
(JPushNotification notification) {
|
||||
setState(() {
|
||||
/// 收到推送
|
||||
print("收到推送提醒: $notification");
|
||||
@ -72,8 +85,8 @@ class _MyAppState extends State<MyApp> {
|
||||
});
|
||||
});
|
||||
|
||||
FlutterJPush
|
||||
.addReceiveOpenNotificationListener((JPushNotification notification) {
|
||||
FlutterJPush.addReceiveOpenNotificationListener(
|
||||
(JPushNotification notification) {
|
||||
setState(() {
|
||||
print("打开了推送提醒: $notification");
|
||||
|
||||
@ -91,13 +104,16 @@ class _MyAppState extends State<MyApp> {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
DataUtils.checkLogin().then((hasLogin) {
|
||||
if (hasLogin.runtimeType == UserInformation) {
|
||||
setState(() {
|
||||
_hasLogin = true;
|
||||
_isLoading = false;
|
||||
_userInfo = hasLogin;
|
||||
// 设置初始化的主题色
|
||||
// if (hasLogin.themeColor != 'default') {
|
||||
// themeColor = int.parse(hasLogin.themeColor);
|
||||
// }
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
@ -112,12 +128,16 @@ class _MyAppState extends State<MyApp> {
|
||||
});
|
||||
print('身份信息验证失败:$onError');
|
||||
});
|
||||
|
||||
ApplicationEvent.event.on<UserSettingThemeColorEvent>().listen((event) {
|
||||
print('接收到的 event $event');
|
||||
});
|
||||
}
|
||||
|
||||
showWelcomePage() {
|
||||
if (_isLoading) {
|
||||
return Container(
|
||||
color: const Color(ThemeColor),
|
||||
color: Color(this.themeColor),
|
||||
child: Center(
|
||||
child: SpinKitPouringHourglass(color: Colors.white),
|
||||
),
|
||||
@ -137,7 +157,7 @@ class _MyAppState extends State<MyApp> {
|
||||
return new MaterialApp(
|
||||
title: 'title',
|
||||
theme: new ThemeData(
|
||||
primaryColor: Color(ThemeColor),
|
||||
primaryColor: Color(this.themeColor),
|
||||
backgroundColor: Color(0xFFEFEFEF),
|
||||
accentColor: Color(0xFF888888),
|
||||
textTheme: TextTheme(
|
||||
@ -145,7 +165,7 @@ class _MyAppState extends State<MyApp> {
|
||||
body1: TextStyle(color: Color(0xFF888888), fontSize: 16.0),
|
||||
),
|
||||
iconTheme: IconThemeData(
|
||||
color: Color(ThemeColor),
|
||||
color: Color(this.themeColor),
|
||||
size: 35.0,
|
||||
),
|
||||
),
|
||||
@ -157,15 +177,12 @@ class _MyAppState extends State<MyApp> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _startupJpush() async {
|
||||
print("初始化jpush");
|
||||
await FlutterJPush.startup();
|
||||
print("初始化jpush成功");
|
||||
}
|
||||
|
||||
|
||||
void main() async {
|
||||
final provider = new Provider();
|
||||
await provider.init(true);
|
||||
@ -173,4 +190,4 @@ void main() async {
|
||||
new SearchHistoryList(sp);
|
||||
db = Provider.db;
|
||||
runApp(new MyApp());
|
||||
}
|
||||
}
|
||||
|
@ -12,13 +12,20 @@ class UserInformation {
|
||||
});
|
||||
|
||||
factory UserInformation.fromJson(Map<String, dynamic> json) {
|
||||
print('fromJOSN $json ${json['id'].runtimeType}');
|
||||
String name = json['name'];
|
||||
int userId ;
|
||||
if(json['name'] == null){
|
||||
name = json['url_name'];
|
||||
}
|
||||
if(json['id'].runtimeType == int){
|
||||
userId = json['id'];
|
||||
}else{
|
||||
userId = int.parse(json['id']);
|
||||
}
|
||||
return UserInformation(
|
||||
avatarPic: json['avatar_pic'],
|
||||
id: int.parse(json['id']),
|
||||
id: userId,
|
||||
username: name,
|
||||
themeColor: json['theme_color']);
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import 'package:flutter_go/views/web_page/web_view_page.dart';
|
||||
import 'package:flutter_go/views/home.dart';
|
||||
import 'package:flutter_go/views/login_page/login_page.dart';
|
||||
import 'package:flutter_go/model/user_info.dart';
|
||||
import 'package:flutter_go/views/issuse_message_page/issuse_message_page.dart';
|
||||
import 'package:flutter_go/views/collection_page/collection_page.dart';
|
||||
import 'package:flutter_go/views/collection_page/collection_full_page.dart';
|
||||
|
||||
@ -66,7 +65,7 @@ var webViewPageHand = new Handler(
|
||||
return new WebViewPage(url, title);
|
||||
});
|
||||
|
||||
var issuesMessageHandler = new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
return issuesMessagePage();
|
||||
});
|
||||
// var issuesMessageHandler = new Handler(
|
||||
// handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
// return issuesMessagePage();
|
||||
// });
|
||||
|
@ -30,7 +30,7 @@ class Routes {
|
||||
router.define(loginPage, handler: loginPageHandler);
|
||||
router.define(codeView,handler:fullScreenCodeDialog);
|
||||
router.define(webViewPage,handler:webViewPageHand);
|
||||
router.define(issuesMessage, handler: issuesMessageHandler);
|
||||
// router.define(issuesMessage, handler: issuesMessageHandler);
|
||||
widgetDemosList.forEach((demo) {
|
||||
Handler handler = new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
|
@ -37,9 +37,13 @@ class DataUtils {
|
||||
// 验证登陆
|
||||
static Future checkLogin() async {
|
||||
var response = await NetUtils.get(Api.CHECK_LOGIN);
|
||||
print('response: $response');
|
||||
try {
|
||||
print('1111');
|
||||
if (response['success']) {
|
||||
print('${response['success']} ${response['data']} response[succes]');
|
||||
UserInformation userInfo = UserInformation.fromJson(response['data']);
|
||||
print('${response['data']} $userInfo');
|
||||
return userInfo;
|
||||
} else {
|
||||
return response['success'];
|
||||
@ -53,12 +57,30 @@ class DataUtils {
|
||||
static Future feedback(Map<String, String> params, context) async {
|
||||
var response = await NetUtils.post(Api.FEEDBACK, params);
|
||||
// print(response);
|
||||
if(response['status'] == 401 && response['message']=='请先登录'){
|
||||
Application.router.navigateTo(context, '${Routes.loginPage}',transition:TransitionType.nativeModal);
|
||||
if (response['status'] == 401 && response['message'] == '请先登录') {
|
||||
Application.router.navigateTo(context, '${Routes.loginPage}',
|
||||
transition: TransitionType.nativeModal);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
//设置主题颜色
|
||||
static Future<bool> setThemeColor(int color, context) async {
|
||||
var response =
|
||||
await NetUtils.post(Api.SET_THEMECOLOR, {'color': color.toString()});
|
||||
if (response['status'] == 401 && response['message'] == '请先登录') {
|
||||
Application.router.navigateTo(context, '${Routes.loginPage}',
|
||||
transition: TransitionType.nativeModal);
|
||||
}
|
||||
return response['success'];
|
||||
}
|
||||
|
||||
//获取主题颜色
|
||||
static Future<String> getThemeColor() async {
|
||||
var response = await NetUtils.get(Api.GET_THEMECOLOR);
|
||||
return response['success'];
|
||||
}
|
||||
|
||||
// 退出登陆
|
||||
static Future<bool> logout() async {
|
||||
var response = await NetUtils.get(Api.LOGOUT);
|
||||
|
@ -19,7 +19,7 @@ class NetUtils {
|
||||
// (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
|
||||
// (HttpClient client) {
|
||||
// client.findProxy = (uri) {
|
||||
// return "PROXY 30.10.24.185:8888";
|
||||
// return "PROXY 30.10.24.79:8889";
|
||||
// };
|
||||
// };
|
||||
|
||||
@ -41,7 +41,7 @@ class NetUtils {
|
||||
// (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
|
||||
// (HttpClient client) {
|
||||
// client.findProxy = (uri) {
|
||||
// return "PROXY 30.10.24.185:8888";
|
||||
// return "PROXY 30.10.24.79:8889";
|
||||
// };
|
||||
// };
|
||||
Directory documentsDir = await getApplicationDocumentsDirectory();
|
||||
|
@ -1,14 +1,27 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fluro/fluro.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_go/components/single_theme_color.dart';
|
||||
import 'package:flutter_go/model/user_info.dart';
|
||||
import 'package:share/share.dart';
|
||||
import 'package:flutter_go/utils/data_utils.dart';
|
||||
import 'package:flutter_go/routers/application.dart';
|
||||
import 'package:flutter_go/routers/routers.dart';
|
||||
import './search_page.dart';
|
||||
import 'package:flutter_go/event/event_bus.dart';
|
||||
import 'package:flutter_go/event/event_model.dart';
|
||||
import 'package:event_bus/event_bus.dart';
|
||||
|
||||
const List<Map<String, dynamic>> defalutThemeColor = [
|
||||
{'cnName': 'Flutter篮', 'value': 0xFF3391EA},
|
||||
{'cnName': '拍卖红', 'value': 0xFFC91B3A},
|
||||
{'cnName': '阿里橙', 'value': 0xFFF7852A},
|
||||
];
|
||||
|
||||
class DrawerPage extends StatefulWidget {
|
||||
final UserInformation userInfo;
|
||||
|
||||
DrawerPage({Key key, this.userInfo}) : super(key: key);
|
||||
|
||||
@override
|
||||
@ -20,53 +33,100 @@ class _DrawerPageState extends State<DrawerPage> {
|
||||
TextStyle(fontSize: 16, fontWeight: FontWeight.w300);
|
||||
bool hasLogin;
|
||||
|
||||
_DrawerPageState() {
|
||||
final eventBus = new EventBus();
|
||||
ApplicationEvent.event = eventBus;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
ApplicationEvent.event.on<UserSettingThemeColorEvent>().listen((event) {
|
||||
print('接收到的 event ${event.settingThemeColor}');
|
||||
});
|
||||
hasLogin = this.widget.userInfo.id != 0;
|
||||
}
|
||||
|
||||
void showLogoutDialog() {
|
||||
if (hasLogin) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('确认退出登陆?'),
|
||||
// content: Text('退出登陆后将没法进行'),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
// 退出登陆
|
||||
DataUtils.logout().then((result) {
|
||||
if (result) {
|
||||
setState(() {
|
||||
hasLogin = false;
|
||||
});
|
||||
Application.router.navigateTo(context, '${Routes.loginPage}',transition:TransitionType.nativeModal,clearStack: true);
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Text('确认',style: TextStyle(color: Colors.red),),
|
||||
Future<AlertDialog> logoutDialog(BuildContext context) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('确认退出登陆?'),
|
||||
// content: Text('退出登陆后将没法进行'),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
onPressed: () {
|
||||
// 退出登陆
|
||||
DataUtils.logout().then((result) {
|
||||
if (result) {
|
||||
Application.router.navigateTo(
|
||||
context, '${Routes.loginPage}',
|
||||
transition: TransitionType.native, clearStack: true);
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
'确认',
|
||||
style: TextStyle(color: Colors.red),
|
||||
),
|
||||
FlatButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text('取消'),
|
||||
)
|
||||
],
|
||||
);
|
||||
});
|
||||
),
|
||||
FlatButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text('取消'),
|
||||
)
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
void showLogoutDialog(BuildContext context) {
|
||||
if (hasLogin) {
|
||||
logoutDialog(context);
|
||||
} else {
|
||||
Application.router.navigateTo(context, '${Routes.loginPage}',transition:TransitionType.native,clearStack: true);
|
||||
Application.router.navigateTo(context, '${Routes.loginPage}',
|
||||
transition: TransitionType.native, clearStack: true);
|
||||
}
|
||||
}
|
||||
|
||||
void pushPage(BuildContext context, Widget page, {String pageName}) {
|
||||
if (context == null || page == null) return;
|
||||
Navigator.push(context, CupertinoPageRoute<void>(builder: (ctx) => page));
|
||||
}
|
||||
|
||||
Future<Dialog> buildSimpleDialog(BuildContext context) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return Dialog(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 20.0),
|
||||
height: 300.0,
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: buildThemeColorChildren(),
|
||||
)),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
List<Widget> buildThemeColorChildren() {
|
||||
List<Widget> tempWidget = [];
|
||||
for (var i = 0; i < defalutThemeColor.length; i++) {
|
||||
tempWidget.add(SingleThemeColor(
|
||||
themeColor: defalutThemeColor[i]['value'],
|
||||
coloeName: defalutThemeColor[i]['cnName'],
|
||||
));
|
||||
}
|
||||
return tempWidget;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print(hasLogin);
|
||||
return ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
children: <Widget>[
|
||||
@ -89,6 +149,19 @@ class _DrawerPageState extends State<DrawerPage> {
|
||||
),
|
||||
),
|
||||
// new Divider(),
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
Icons.search,
|
||||
size: 27.0,
|
||||
),
|
||||
title: Text(
|
||||
'搜索',
|
||||
style: textStyle,
|
||||
),
|
||||
onTap: () {
|
||||
pushPage(context, SearchPage(), pageName: "SearchPage");
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
Icons.favorite,
|
||||
@ -99,21 +172,25 @@ class _DrawerPageState extends State<DrawerPage> {
|
||||
style: textStyle,
|
||||
),
|
||||
onTap: () {
|
||||
Application.router.navigateTo(context, '${Routes.collectionFullPage}?hasLogin=${hasLogin.toString()}',transition: TransitionType.fadeIn);
|
||||
Application.router.navigateTo(context,
|
||||
'${Routes.collectionFullPage}?hasLogin=${hasLogin.toString()}',
|
||||
transition: TransitionType.fadeIn);
|
||||
},
|
||||
),
|
||||
// new Divider(),
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
Icons.settings,
|
||||
size: 27.0,
|
||||
),
|
||||
title: Text(
|
||||
'更多设置',
|
||||
style: textStyle,
|
||||
),
|
||||
onTap: () {},
|
||||
),
|
||||
// ListTile(
|
||||
// leading: Icon(
|
||||
// Icons.settings,
|
||||
// size: 27.0,
|
||||
// ),
|
||||
// title: Text(
|
||||
// '主题色',
|
||||
// style: textStyle,
|
||||
// ),
|
||||
// onTap: () {
|
||||
// buildSimpleDialog(context);
|
||||
// },
|
||||
// ),
|
||||
new Divider(),
|
||||
|
||||
ListTile(
|
||||
@ -129,27 +206,27 @@ class _DrawerPageState extends State<DrawerPage> {
|
||||
if (hasLogin) {
|
||||
//issue 未登陆状态 返回登陆页面
|
||||
DataUtils.logout().then((result) {
|
||||
Application.router.navigateTo(context, '${Routes.issuesMessage}');
|
||||
Application.router
|
||||
.navigateTo(context, '${Routes.issuesMessage}');
|
||||
});
|
||||
} else {
|
||||
//No description provided.
|
||||
Application.router.navigateTo(context, '${Routes.loginPage}');
|
||||
// Application.router.navigateTo(context, '${Routes.issuesMessage}');
|
||||
// Application.router.navigateTo(context, '${Routes.issuesMessage}');
|
||||
}
|
||||
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
Icons.info,
|
||||
size: 27.0,
|
||||
),
|
||||
title: Text(
|
||||
'关于 App',
|
||||
style: textStyle,
|
||||
),
|
||||
onTap: () {},
|
||||
),
|
||||
// ListTile(
|
||||
// leading: Icon(
|
||||
// Icons.info,
|
||||
// size: 27.0,
|
||||
// ),
|
||||
// title: Text(
|
||||
// '关于 App',
|
||||
// style: textStyle,
|
||||
// ),
|
||||
// onTap: () {},
|
||||
// ),
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
Icons.share,
|
||||
@ -173,7 +250,10 @@ class _DrawerPageState extends State<DrawerPage> {
|
||||
hasLogin ? '退出登陆' : '点击登录',
|
||||
style: textStyle,
|
||||
),
|
||||
onTap: showLogoutDialog,
|
||||
onTap: () {
|
||||
showLogoutDialog(context);
|
||||
// logoutDialog(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
|
@ -24,7 +24,6 @@ class MainPage extends StatelessWidget {
|
||||
final UserInformation userInfo;
|
||||
|
||||
MainPage({Key key, this.userInfo}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print("MainPagess build......");
|
||||
@ -51,7 +50,7 @@ class MainPage extends StatelessWidget {
|
||||
),
|
||||
drawer: Drawer(
|
||||
child: DrawerPage(
|
||||
userInfo: userInfo,
|
||||
userInfo: userInfo
|
||||
),
|
||||
),
|
||||
body: TabBarViewLayout(),
|
||||
|
@ -22,7 +22,6 @@ import 'package:flutter_go/model/search_history.dart';
|
||||
import 'package:flutter_go/resources/widget_name_to_icon.dart';
|
||||
import 'package:flutter_go/model/user_info.dart';
|
||||
|
||||
const int ThemeColor = 0xFFC91B3A;
|
||||
|
||||
class AppPage extends StatefulWidget {
|
||||
|
||||
@ -57,6 +56,7 @@ class _MyHomePageState extends State<AppPage>
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
print('widget.userInfo ${widget.userInfo}');
|
||||
initSearchHistory();
|
||||
for (int i = 0; i < tabData.length; i++) {
|
||||
_myTabs.add(BottomNavigationBarItem(
|
||||
@ -148,7 +148,7 @@ class _MyHomePageState extends State<AppPage>
|
||||
//fixed:固定
|
||||
type: BottomNavigationBarType.fixed,
|
||||
|
||||
fixedColor: Color(0xFFC91B3A),
|
||||
fixedColor: Theme.of(context).primaryColor,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -1,133 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:zefyr/zefyr.dart';
|
||||
import 'package:flutter_go/utils/data_utils.dart';
|
||||
import 'package:notus/convert.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
|
||||
class issuesMessagePage extends StatefulWidget {
|
||||
@override
|
||||
_issuesMessagePageState createState() => _issuesMessagePageState();
|
||||
}
|
||||
|
||||
class _issuesMessagePageState extends State<issuesMessagePage> {
|
||||
final TextEditingController _controller = new TextEditingController();
|
||||
final ZefyrController _zefyrController = new ZefyrController(NotusDocument());
|
||||
final FocusNode _focusNode = new FocusNode();
|
||||
String _title = "";
|
||||
var _delta;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_controller.addListener(() {
|
||||
print("_controller.text:${_controller.text}");
|
||||
setState(() {
|
||||
_title = _controller.text;
|
||||
});
|
||||
});
|
||||
|
||||
_zefyrController.document.changes.listen((change) {
|
||||
setState(() {
|
||||
_delta = _zefyrController.document.toDelta();
|
||||
});
|
||||
});
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
_zefyrController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
_submit() {
|
||||
String mk = notusMarkdown.encode(_delta);
|
||||
if (_title.trim().isEmpty) {
|
||||
_show('标题不能为空');
|
||||
} else {
|
||||
DataUtils.feedback({'title': _title, "body": mk},context).then((result) {
|
||||
_show(result);
|
||||
Navigator.maybePop(context);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_show(String msgs){
|
||||
Fluttertoast.showToast(
|
||||
msg: msgs,
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.CENTER,
|
||||
timeInSecForIos: 1,
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
textColor: Colors.white,
|
||||
fontSize: 16.0);
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('反馈/意见'),
|
||||
actions: <Widget>[
|
||||
FlatButton.icon(
|
||||
onPressed: () {
|
||||
_submit();
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.near_me,
|
||||
color: Colors.white,
|
||||
size: 12,
|
||||
),
|
||||
label: Text(
|
||||
'发送',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
)
|
||||
],
|
||||
elevation: 1.0,
|
||||
),
|
||||
body: ZefyrScaffold(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
Text('输入标题:'),
|
||||
new TextFormField(
|
||||
maxLength: 50,
|
||||
controller: _controller,
|
||||
decoration: new InputDecoration(
|
||||
hintText: 'Title',
|
||||
),
|
||||
),
|
||||
Text('内容:'),
|
||||
_descriptionEditor(),
|
||||
],
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
Widget _descriptionEditor() {
|
||||
final theme = new ZefyrThemeData(
|
||||
toolbarTheme: ZefyrToolbarTheme.fallback(context).copyWith(
|
||||
color: Colors.grey.shade800,
|
||||
toggleColor: Colors.grey.shade900,
|
||||
iconColor: Colors.white,
|
||||
disabledIconColor: Colors.grey.shade500,
|
||||
),
|
||||
);
|
||||
|
||||
return ZefyrTheme(
|
||||
data: theme,
|
||||
child: ZefyrField(
|
||||
height: 400.0,
|
||||
decoration: InputDecoration(labelText: 'Description'),
|
||||
controller: _zefyrController,
|
||||
focusNode: _focusNode,
|
||||
autofocus: true,
|
||||
physics: ClampingScrollPhysics(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -56,7 +56,7 @@ class _WebViewPageState extends State<WebViewPage> {
|
||||
|
||||
flutterWebviewPlugin.close();
|
||||
// 验证成功
|
||||
} else if (url.indexOf('${Api.RedirectIp}loginFail') == 0) {
|
||||
} else if (url.indexOf('${Api.BASE_URL}loginFail') == 0) {
|
||||
// 验证失败
|
||||
if (ApplicationEvent.event != null) {
|
||||
ApplicationEvent.event.fire(UserGithubOAuthEvent('', '', true));
|
||||
|
54
pubspec.lock
54
pubspec.lock
@ -14,7 +14,7 @@ packages:
|
||||
name: async
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
version: "2.2.0"
|
||||
bloc:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -28,7 +28,7 @@ packages:
|
||||
name: boolean_selector
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
version: "1.0.4"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -56,14 +56,14 @@ packages:
|
||||
name: cookie_jar
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
version: "1.0.1"
|
||||
csslib:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: csslib
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.16.0"
|
||||
version: "0.16.1"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -77,7 +77,7 @@ packages:
|
||||
name: dio
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.1.7"
|
||||
version: "2.1.13"
|
||||
event_bus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -214,13 +214,6 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.6"
|
||||
notus:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: notus
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.3"
|
||||
open_file:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -248,14 +241,14 @@ packages:
|
||||
name: path_provider
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.1.2"
|
||||
pedantic:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pedantic
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.5.0"
|
||||
version: "1.7.0"
|
||||
permission_handler:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -263,27 +256,13 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.1.0"
|
||||
quill_delta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: quill_delta
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
quiver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: quiver
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
quiver_hashcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: quiver_hashcode
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
version: "2.0.3"
|
||||
rxdart:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -297,7 +276,7 @@ packages:
|
||||
name: share
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.6.1+1"
|
||||
version: "0.6.2"
|
||||
shared_preferences:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -323,7 +302,7 @@ packages:
|
||||
name: sqflite
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.5"
|
||||
version: "1.1.6+1"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -365,7 +344,7 @@ packages:
|
||||
name: test_api
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.2.4"
|
||||
version: "0.2.5"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -379,7 +358,7 @@ packages:
|
||||
name: url_launcher
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "5.0.3"
|
||||
version: "5.0.5"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -387,13 +366,6 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.0.8"
|
||||
zefyr:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: zefyr
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.5.0"
|
||||
sdks:
|
||||
dart: ">=2.2.0 <3.0.0"
|
||||
dart: ">=2.2.2 <3.0.0"
|
||||
flutter: ">=1.5.0 <2.0.0"
|
||||
|
@ -48,7 +48,7 @@ dependencies:
|
||||
open_file: ^2.0.1+2
|
||||
package_info: ^0.4.0+3
|
||||
flutter_jpush: ^0.0.4
|
||||
zefyr: ^0.5.0
|
||||
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
Reference in New Issue
Block a user