消息反馈页面

This commit is contained in:
xiaojia.dxj
2019-06-28 11:14:34 +08:00
parent db9c4caba6
commit 90e1cbf11c
7 changed files with 202 additions and 35 deletions

View File

@ -8,6 +8,7 @@ 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';
// app的首页
var homeHandler = new Handler(
@ -26,24 +27,29 @@ var categoryHandler = new Handler(
var widgetNotFoundHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
return new WidgetNotFound();
});
return new WidgetNotFound();
});
var loginPageHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
return LoginPage();
});
return LoginPage();
});
var fullScreenCodeDialog = new Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
String path = params['filePath']?.first;
return new FullScreenCodeDialog(
filePath: path,
);
});
String path = params['filePath']?.first;
return new FullScreenCodeDialog(
filePath: path,
);
});
var webViewPageHand = new Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
String title = params['title']?.first;
String url = params['url']?.first;
return new WebViewPage(url, title);
});
String title = params['title']?.first;
String url = params['url']?.first;
return new WebViewPage(url, title);
});
var issuesMessageHandler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
return issuesMessagePage();
});

View File

@ -13,6 +13,7 @@ class Routes {
static String codeView = '/code-view';
static String webViewPage = '/web-view-page';
static String loginPage = '/loginpage';
static String issuesMessage='/issuesMessage';
static void configureRoutes(Router router) {
List widgetDemosList = new WidgetDemoList().getDemos();
@ -26,6 +27,7 @@ class Routes {
router.define(loginPage, handler: loginPageHandler);
router.define(codeView,handler:fullScreenCodeDialog);
router.define(webViewPage,handler:webViewPageHand);
router.define(issuesMessage, handler: issuesMessageHandler);
widgetDemosList.forEach((demo) {
Handler handler = new Handler(
handlerFunc: (BuildContext context, Map<String, List<String>> params) {

View File

@ -85,12 +85,16 @@ class _DrawerPageState extends State<DrawerPage> {
style: textStyle,
),
onTap: () {
DataUtils.feedback({
'title': "这是客户端 FeedBack title",
"body": "这是客户端 FeedBack body"
}).then((result) {
print(result);
});
if (hasLogin) {
//issue 未登陆状态 返回登陆页面
DataUtils.logout().then((result) {
Application.router.navigateTo(context, '${Routes.issuesMessage}');
});
} else {
//No description provided.
// Application.router.navigateTo(context, '${Routes.loginPage}');
Application.router.navigateTo(context, '${Routes.issuesMessage}');
}
},
),
ListTile(

View File

@ -0,0 +1,126 @@
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) {
Fluttertoast.showToast(msg: '标题不能为空',
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIos: 1,
backgroundColor: Theme.of(context).primaryColor,
textColor: Colors.white,
fontSize: 16.0);
} else {
DataUtils.feedback({'title': _title, "body": mk}).then((result) {
print(result);
});
}
}
@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(),
),
);
}
}

View File

@ -30,7 +30,7 @@ class _Demo extends State<Demo> {
return WidgetDemo(
title: 'Rich Text',
docUrl: 'https://docs.flutter.io/flutter/widgets/RichText-class.html',
codeUrl: 'elements/Form/Text/RichText/index.dart',
codeUrl: 'elements/Form/Text/RichText/demo.dart',
contentList: [
intro,
RichTextDemo(),