Merge pull request #294 from Nealyang/beta

Feat:收藏功能、搜索功能、个人中心功能完善
This commit is contained in:
一凨
2019-08-06 17:06:05 +08:00
committed by GitHub
14 changed files with 297 additions and 246 deletions

View File

@ -1,2 +1,3 @@
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
#include "../Pods/Target\ Support\ Files/Pods-Runner/Pods-Runner.debug.xcconfig"

View File

@ -1,2 +1,3 @@
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
#include "../Pods/Target\ Support\ Files/Pods-Runner/Pods-Runner.release.xcconfig"

View File

@ -32,6 +32,16 @@
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
FA240D7922F2857D003025F3 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAD0115F22F1B9DF0016E673 /* Flutter.framework */; };
FA240D7A22F2857D003025F3 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = FAD0115F22F1B9DF0016E673 /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
FA240D7B22F28581003025F3 /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAD0116122F1B9DF0016E673 /* App.framework */; };
FA240D7C22F28581003025F3 /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = FAD0116122F1B9DF0016E673 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
FAD0116422F1B9DF0016E673 /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = FAD0115E22F1B9DF0016E673 /* Debug.xcconfig */; };
FAD0116522F1B9DF0016E673 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAD0115F22F1B9DF0016E673 /* Flutter.framework */; };
FAD0116622F1B9DF0016E673 /* Release.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = FAD0116022F1B9DF0016E673 /* Release.xcconfig */; };
FAD0116722F1B9DF0016E673 /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAD0116122F1B9DF0016E673 /* App.framework */; };
FAD0116822F1B9DF0016E673 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = FAD0116222F1B9DF0016E673 /* AppFrameworkInfo.plist */; };
FAD0116922F1B9DF0016E673 /* Generated.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = FAD0116322F1B9DF0016E673 /* Generated.xcconfig */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@ -41,6 +51,8 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
FA240D7C22F28581003025F3 /* App.framework in Embed Frameworks */,
FA240D7A22F2857D003025F3 /* Flutter.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
@ -80,6 +92,12 @@
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A4868A865F318D337B7500AF /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
B7B77D3AD1E975E5BE03D770 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
FAD0115E22F1B9DF0016E673 /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
FAD0115F22F1B9DF0016E673 /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Flutter.framework; sourceTree = "<group>"; };
FAD0116022F1B9DF0016E673 /* Release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
FAD0116122F1B9DF0016E673 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = App.framework; sourceTree = "<group>"; };
FAD0116222F1B9DF0016E673 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = AppFrameworkInfo.plist; sourceTree = "<group>"; };
FAD0116322F1B9DF0016E673 /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Generated.xcconfig; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -88,6 +106,10 @@
buildActionMask = 2147483647;
files = (
17DB4C25EDB98B3648015B9E /* libPods-Runner.a in Frameworks */,
FAD0116722F1B9DF0016E673 /* App.framework in Frameworks */,
FAD0116522F1B9DF0016E673 /* Flutter.framework in Frameworks */,
FA240D7922F2857D003025F3 /* Flutter.framework in Frameworks */,
FA240D7B22F28581003025F3 /* App.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -127,6 +149,7 @@
97C146E51CF9000F007C117D = {
isa = PBXGroup;
children = (
FAD0115D22F1B9DF0016E673 /* Flutter */,
0828E485220692A700A59437 /* launch */,
084A20872202E4FD00428FF5 /* flutter go.png */,
97C146F01CF9000F007C117D /* Runner */,
@ -180,6 +203,19 @@
path = Pods;
sourceTree = "<group>";
};
FAD0115D22F1B9DF0016E673 /* Flutter */ = {
isa = PBXGroup;
children = (
FAD0115E22F1B9DF0016E673 /* Debug.xcconfig */,
FAD0115F22F1B9DF0016E673 /* Flutter.framework */,
FAD0116022F1B9DF0016E673 /* Release.xcconfig */,
FAD0116122F1B9DF0016E673 /* App.framework */,
FAD0116222F1B9DF0016E673 /* AppFrameworkInfo.plist */,
FAD0116322F1B9DF0016E673 /* Generated.xcconfig */,
);
path = Flutter;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@ -250,6 +286,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
FAD0116622F1B9DF0016E673 /* Release.xcconfig in Resources */,
0828E4A0220692B500A59437 /* iPad Landscape.png in Resources */,
0828E4A1220692B500A59437 /* iPhone XR Portrait.png in Resources */,
0828E49F220692B500A59437 /* iPhone XS Max Landscape.png in Resources */,
@ -260,14 +297,17 @@
0828E49E220692B500A59437 /* iPad Portrait@2x.png in Resources */,
0828E49D220692B500A59437 /* iPhone Portrait@2x.png in Resources */,
0828E499220692B500A59437 /* iPhone Portrait-Retina HD 4.7.png in Resources */,
FAD0116822F1B9DF0016E673 /* AppFrameworkInfo.plist in Resources */,
084A20882202E4FD00428FF5 /* flutter go.png in Resources */,
0828E497220692B500A59437 /* iPhone X_XS Landscape.png in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
0828E4A52206936100A59437 /* Images.xcassets in Resources */,
FAD0116922F1B9DF0016E673 /* Generated.xcconfig in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
0828E49B220692B500A59437 /* iPad Landscape@2x.png in Resources */,
0828E495220692B500A59437 /* iPhone Portrait-Retina 4.png in Resources */,
0828E498220692B500A59437 /* iPhone XS Max Portrait.png in Resources */,
FAD0116422F1B9DF0016E673 /* Debug.xcconfig in Resources */,
94722E5C22511D3600F63900 /* GoogleService-Info.plist in Resources */,
0828E496220692B500A59437 /* iPad Portrait.png in Resources */,
0828E49C220692B500A59437 /* iPhone Landscape-Retina HD 5.5.png in Resources */,
@ -289,11 +329,11 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
shellScript = "/bin/sh \"/Users/nealyang/development/flutter/packages/flutter_tools/bin/xcode_backend.sh\" thin\n";
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
buildActionMask = 12;
files = (
);
inputPaths = (
@ -303,7 +343,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n";
};
B34D03FFEA3831330E64E5C7 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
@ -506,7 +546,7 @@
};
97C147061CF9000F007C117D /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = A4868A865F318D337B7500AF /* Pods-Runner.debug.xcconfig */;
baseConfigurationReference = FAD0115E22F1B9DF0016E673 /* Debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = Launch2;
@ -537,7 +577,7 @@
};
97C147071CF9000F007C117D /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = B7B77D3AD1E975E5BE03D770 /* Pods-Runner.release.xcconfig */;
baseConfigurationReference = FAD0116022F1B9DF0016E673 /* Release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = Launch2;

View File

@ -23,11 +23,14 @@ class Api{
static const String ADD_COLLECTION = BASE_URL+'auth/addCollection';//添加收藏
static const String CHECK_COLLECTED = BASE_URL+'auth/checkCollected';//校验收藏
static const String CHECK_COLLECTED = BASE_URL+'checkCollected';//校验收藏
static const String SET_THEMECOLOR = BASE_URL+'auth/setThemeColor';//设置主题颜色
static const String GET_THEMECOLOR = BASE_URL +'/getThemeColor';//获取主题颜色
static const String GET_WIDGET_TREE = 'http://flutter-go.alibaba.net/' + 'getCateList';//获取widget列表树
static const String SEARCH_WIDGET = BASE_URL+'searchWidget';//搜索组件
}

View File

@ -4,6 +4,7 @@
import 'dart:core';
import 'package:flutter/material.dart';
import 'package:flutter_go/utils/data_utils.dart';
import '../routers/application.dart';
import '../routers/routers.dart';
@ -37,7 +38,7 @@ class _WidgetDemoState extends State<WidgetDemo> {
CollectionControlModel _collectionControl = new CollectionControlModel();
var _collectionIcons;
List widgetDemosList = new WidgetDemoList().getDemos();
String _router = '';
String widgetType = 'old';
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
List<Widget> _buildContent() {
@ -65,60 +66,66 @@ class _WidgetDemoState extends State<WidgetDemo> {
void initState() {
super.initState();
// 这里不能直接 使用 ` ModalRoute.of(context)` 会产生报错
Future.delayed(Duration.zero,() {
Future.delayed(Duration.zero, () {
String currentPath = ModalRoute.of(context).settings.name;
_collectionControl.getRouterByUrl(currentPath).then((list) {
if (currentPath.indexOf('/standard-page') == 0) {
widgetType = 'standard';
}
Map<String, String> params = {
'type': widgetType,
"url": currentPath,
"name": widget.title
};
DataUtils.checkCollected(params).then((result) {
if (this.mounted) {
setState(() {
_hasCollected = list.length > 0;
_hasCollected = result;
});
}
});
});
}
// 点击收藏按钮
_getCollection() {
String currentRouterPath = ModalRoute.of(context).settings.name;
Map<String, String> params = {
"type": widgetType,
"url": currentRouterPath,
"name": widget.title
};
if (_hasCollected) {
// 删除操作
_collectionControl.deleteByPath(currentRouterPath).then((result) {
if (result > 0 && this.mounted) {
setState(() {
_hasCollected = false;
});
DataUtils.removeCollected(params, context).then((result) {
if (result) {
_scaffoldKey.currentState
.showSnackBar(SnackBar(content: Text('已取消收藏')));
if (ApplicationEvent.event != null) {
ApplicationEvent.event
.fire(CollectionEvent(widget.title, currentRouterPath, true));
}
return;
if (this.mounted) {
setState(() {
_hasCollected = false;
});
}
}
print('删除错误');
});
} else {
// 插入操作
_collectionControl
.insert(Collection(name: widget.title, router: currentRouterPath))
.then((result) {
if (this.mounted) {
setState(() {
_hasCollected = true;
});
DataUtils.addCollected(params, context).then((result) {
if (result) {
if (this.mounted) {
setState(() {
_hasCollected = true;
});
}
_scaffoldKey.currentState
.showSnackBar(SnackBar(content: Text('收藏成功')));
if (ApplicationEvent.event != null) {
ApplicationEvent.event
.fire(CollectionEvent(widget.title, currentRouterPath, false));
}
_scaffoldKey.currentState
.showSnackBar(SnackBar(content: Text('收藏成功')));
}
});
}
@ -162,28 +169,28 @@ class _WidgetDemoState extends State<WidgetDemo> {
PopupMenuButton<String>(
onSelected: _selectValue,
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
const PopupMenuItem<String>(
value: 'doc',
child: ListTile(
leading: Icon(
Icons.library_books,
size: 22.0,
),
title: Text('查看文档'),
),
const PopupMenuItem<String>(
value: 'doc',
child: ListTile(
leading: Icon(
Icons.library_books,
size: 22.0,
),
const PopupMenuDivider(),
const PopupMenuItem<String>(
value: 'code',
child: ListTile(
leading: Icon(
Icons.code,
size: 22.0,
),
title: Text('查看Demo'),
),
title: Text('查看文档'),
),
),
const PopupMenuDivider(),
const PopupMenuItem<String>(
value: 'code',
child: ListTile(
leading: Icon(
Icons.code,
size: 22.0,
),
],
title: Text('查看Demo'),
),
),
],
),
],
),

View File

@ -190,8 +190,8 @@ void main() async {
sp = await SpUtil.getInstance();
new SearchHistoryList(sp);
await DataUtils.getWidgetTreeList().then((List json) {
if (json == null) return;
Application.widgetTree = WidgetTree.buildWidgetTree(json);
});
db = Provider.db;
runApp(new MyApp());

View File

@ -1,7 +1,9 @@
import 'dart:async' show Future;
import 'package:fluro/fluro.dart';
import 'package:flutter_go/model/collection.dart';
import 'package:flutter_go/model/version.dart';
import 'package:flutter_go/model/widget.dart';
import 'package:package_info/package_info.dart';
import 'package:flutter_go/model/responseData.dart';
@ -39,7 +41,6 @@ class DataUtils {
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']);
@ -104,15 +105,97 @@ class DataUtils {
return false;
}
}
/// 获取widget列表处的树型数据
static Future<List> getWidgetTreeList() async {
var response = await NetUtils.get(Api.GET_WIDGET_TREE);
try {
var response = await NetUtils.get(Api.GET_WIDGET_TREE);
print('组件树:$response');
if (response != null && response['success']) {
return response['data'];
} else {
return [];
}
} catch (error) {
print('获取组件树 error $error');
}
}
if (response['success']) {
return response['data'];
// 校验是否收藏
static Future<bool> checkCollected(Map<String, String> params) async {
print('url 地址:${Api.CHECK_COLLECTED} $params');
try {
var response = await NetUtils.post(Api.CHECK_COLLECTED, params);
return response != null && response['hasCollected'];
} catch (error) {
print('校验收藏 error $error');
}
}
// 添加收藏
static Future addCollected(Map<String, String> params, context) async {
var response = await NetUtils.post(Api.ADD_COLLECTION, params);
if (response['status'] == 401 && response['message'] == '请先登录') {
Application.router.navigateTo(context, '${Routes.loginPage}',
transition: TransitionType.nativeModal);
}
return response != null && response['success'];
}
// 移出收藏
static Future removeCollected(Map<String, String> params, context) async {
var response = await NetUtils.post(Api.REMOVE_COLLECTION, params);
if (response['status'] == 401 && response['message'] == '请先登录') {
Application.router.navigateTo(context, '${Routes.loginPage}',
transition: TransitionType.nativeModal);
}
return response != null && response['success'];
}
// 获取全部收藏
static Future getAllCollections(context) async {
var response = await NetUtils.get(Api.GET_ALL_COLLECTION);
List<Collection> responseList = [];
if (response['status'] == 401 && response['message'] == '请先登录') {
Application.router.navigateTo(context, '${Routes.loginPage}',
transition: TransitionType.nativeModal);
}
if (response != null && response['success'] == true) {
for (int i = 0; i < response['data'].length; i++) {
Map<String, dynamic> tempCo = response['data'][i];
responseList.add(Collection.fromJSON(
{"name": tempCo['name'], "router": tempCo['url']}));
}
return responseList;
} else {
return [];
}
}
// 搜索组件
static Future searchWidget(String name) async {
var response = await NetUtils.get(Api.SEARCH_WIDGET, {"name": name});
List<WidgetPoint> list = [];
if (response != null && response['success'] == true) {
for (int i = 0; i < response['data'].length; i++) {
var json = response['data'][i];
String routerName;
if (json['display'] == 'old') {
routerName = json['path'];
} else {
routerName = json['pageId'];
}
Map<String, dynamic> tempMap = {
"name": json['name'],
"cnName": json['name'],
"routerName": routerName,
"catId": int.parse(json['parentId'])
};
list.add(WidgetPoint.fromJSON(tempMap));
}
return list;
} else {
return [];
}
}
}

View File

@ -4,12 +4,13 @@
/// @Last Modified time: 2019-06-05 14:01:03
import 'package:flutter/material.dart';
import 'package:event_bus/event_bus.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter_go/model/collection.dart';
import 'package:flutter_go/routers/application.dart';
import 'package:flutter_go/routers/routers.dart';
import 'package:flutter_go/event/event_bus.dart';
import 'package:flutter_go/event/event_model.dart';
import 'package:flutter_go/utils/data_utils.dart';
class CollectionFullPage extends StatefulWidget {
final bool hasLogined;
@ -41,13 +42,10 @@ class _CollectionFullPageState extends State<CollectionFullPage> {
void _getList() {
_collectionList.clear();
_collectionControl.getAllCollection().then((resultList) {
resultList.forEach((item) {
_collectionList.add(item);
});
DataUtils.getAllCollections(context).then((collectionList) {
if (this.mounted) {
setState(() {
_collectionList = _collectionList;
_collectionList = collectionList;
});
}
});
@ -73,7 +71,7 @@ class _CollectionFullPageState extends State<CollectionFullPage> {
SizedBox(
width: 5.0,
),
Text('模拟器重新运行会丢失收藏'),
Text('常用的组件都可以收藏在这里哦'),
],
),
);
@ -115,21 +113,24 @@ class _CollectionFullPageState extends State<CollectionFullPage> {
trailing:
Icon(Icons.keyboard_arrow_right, color: Colors.grey, size: 30.0),
onTap: () {
if (_collectionList[index - 1].router.contains('http')) {
// 注意这里title已经转义过了
Application.router.navigateTo(context,
'${Routes.webViewPage}?title=${_collectionList[index - 1].name}&url=${Uri.encodeComponent(_collectionList[index - 1].router)}');
} else {
Application.router
.navigateTo(context, "${_collectionList[index - 1].router}");
}
Application.router.navigateTo(
context, _collectionList[index - 1].router,
transition: TransitionType.inFromRight);
// if (_collectionList[index - 1].router.contains('http')) {
// // 注意这里title已经转义过了
// Application.router.navigateTo(context,
// '${Routes.webViewPage}?title=${_collectionList[index - 1].name}&url=${Uri.encodeComponent(_collectionList[index - 1].router)}');
// } else {
// Application.router
// .navigateTo(context, "${_collectionList[index - 1].router}");
// }
},
),
);
}
ListView buildContent(){
ListView buildContent() {
if (_collectionList.length == 0) {
return ListView(
children: <Widget>[

View File

@ -11,6 +11,7 @@ import 'package:flutter_go/routers/application.dart';
import 'package:flutter_go/routers/routers.dart';
import 'package:flutter_go/event/event_bus.dart';
import 'package:flutter_go/event/event_model.dart';
import 'package:flutter_go/utils/data_utils.dart';
class CollectionPage extends StatefulWidget {
final bool hasLogined;
@ -47,14 +48,10 @@ class _CollectionPageState extends State<CollectionPage> {
void _getList() {
_collectionList.clear();
_collectionControl.getAllCollection().then((resultList) {
resultList.forEach((item) {
_collectionList.add(item);
});
print("_collectionList ${_collectionList}");
DataUtils.getAllCollections(context).then((collectionList) {
if (this.mounted) {
setState(() {
_collectionList = _collectionList;
_collectionList = collectionList;
});
}
});

View File

@ -7,9 +7,11 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_go/utils/data_utils.dart';
import 'package:flutter_go/utils/shared_preferences.dart';
import 'package:flutter_go/views/first_page/first_page.dart';
import 'package:flutter_go/views/first_page/main_page.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter_go/views/widget_page/widget_page.dart';
import 'package:flutter_go/views/welcome_page/fourth_page.dart';
import 'package:flutter_go/views/collection_page/collection_page.dart';
@ -87,26 +89,21 @@ class _MyHomePageState extends State<AppPage>
}
void onWidgetTap(WidgetPoint widgetPoint, BuildContext context) {
List widgetDemosList = new WidgetDemoList().getDemos();
String targetName = widgetPoint.name;
String targetRouter = '/category/error/404';
widgetDemosList.forEach((item) {
if (item.name == targetName) {
targetRouter = item.routerName;
}
});
searchHistoryList
.add(SearchHistory(name: targetName, targetRouter: targetRouter));
.add(SearchHistory(name: targetName, targetRouter: widgetPoint.routerName));
print("searchHistoryList1 ${searchHistoryList.toString()}");
print("searchHistoryList2 ${targetRouter}");
print("searchHistoryList3 ${widgetPoint.name}");
Application.router.navigateTo(context, "$targetRouter");
Application.router.navigateTo(
context, widgetPoint.routerName,
transition: TransitionType.inFromRight);
}
Widget buildSearchInput(BuildContext context) {
return new SearchInput((value) async {
if (value != '') {
List<WidgetPoint> list = await widgetControl.search(value);
print('value ::: $value');
// List<WidgetPoint> list = await widgetControl.search(value);
List<WidgetPoint> list = await DataUtils.searchWidget(value);
return list
.map((item) => new MaterialSearchResult<String>(
value: item.name,

View File

@ -27,7 +27,6 @@ class StandardView extends StatefulWidget {
_StandardView createState() => _StandardView();
}
class _StandardView extends State<StandardView> {
String markdownDesc = '# this is header';
String pageTitle = "XXX";
@ -37,15 +36,17 @@ class _StandardView extends State<StandardView> {
StandardPages standardPage = new StandardPages();
@override
void initState() {
super.initState();
this.getDetail();
}
// 本地调用的获取基本信息
Future<void> getPagesInfo() async {
String jsonString = await DefaultAssetBundle.of(context).loadString('lib/standard_pages/.pages.json');
String jsonString = await DefaultAssetBundle.of(context)
.loadString('lib/standard_pages/.pages.json');
List jsonList = json.decode(jsonString);
Map<String, dynamic> pageDetail = jsonList.firstWhere((item) => item['id'] == widget.id);
Map<String, dynamic> pageDetail =
jsonList.firstWhere((item) => item['id'] == widget.id);
if (pageDetail != null) {
setState(() {
pageTitle = pageDetail['title'] ?? '请加入title';
@ -53,16 +54,14 @@ class _StandardView extends State<StandardView> {
email = pageDetail['email'];
});
}
}
String _getContentFromLocal() {
String pageId = widget.id;
Map<String, String> pagesList = standardPage.getPages();
return pagesList[pageId];
}
Future<String> _getContentOnline() async {
String content = 'online content';
@ -79,12 +78,15 @@ class _StandardView extends State<StandardView> {
getPagesInfo();
conent = _getContentFromLocal();
}
setState(() {
markdownDesc = conent;
});
if (this.mounted) {
setState(() {
markdownDesc = conent;
});
}
return Future(() => conent);
// this.rebuild();
}
Widget buildMarkdown() {
Map<String, String> contentList = new StandardPages().getPages();
@ -94,23 +96,19 @@ class _StandardView extends State<StandardView> {
return MarkdownBody(
data: contentList[widget.id],
syntaxHighlighter:new mdCopy.HighLight(),
syntaxHighlighter: new mdCopy.HighLight(),
demoBuilder: (Map<String, dynamic> attrs) {
List<Widget> demo = demoObjects[attrs['id']];
if (demo == null) {
String errString = "not found ${attrs['id']} in demo packages";
debugPrint(errString);
demo = [
Text(errString)
];
demo = [Text(errString)];
}
return Column(
children: demo
);
}
);
return Column(children: demo);
});
}
@override
Widget build(BuildContext context) {
return new WidgetDemo(
@ -123,7 +121,8 @@ class _StandardView extends State<StandardView> {
'创建者: $email',
'id: ${widget.id}',
],
docUrl: 'https://docs.flutter.io/flutter/material/DropdownButton-class.html',
docUrl:
'https://docs.flutter.io/flutter/material/DropdownButton-class.html',
);
}
}
}

View File

@ -23,10 +23,6 @@ class WebViewPage extends StatefulWidget {
class _WebViewPageState extends State<WebViewPage> {
final flutterWebviewPlugin = new FlutterWebviewPlugin();
bool _hasCollected = false;
String _router = '';
var _collectionIcons;
CollectionControlModel _collectionControl = new CollectionControlModel();
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@override
@ -65,87 +61,14 @@ class _WebViewPageState extends State<WebViewPage> {
flutterWebviewPlugin.close();
}
});
// 这里 存放不使用 name 改成 url. 确定唯一性
// _collectionControl
// .getRouterByName(Uri.encodeComponent(widget.title.trim()))
// .then((list) {
// list.forEach((item) {
// if (widget.title.trim() == item['name']) {
// _router = item['router'];
// }
// });
// if (mounted) {
// setState(() {
// _hasCollected = list.length > 0;
// });
// }
// });
}
// 点击收藏按钮
_getCollection() {
if (_hasCollected) {
// 删除操作
_collectionControl
.deleteByName(Uri.encodeComponent(widget.title.trim()))
.then((result) {
if (result > 0 && this.mounted) {
setState(() {
_hasCollected = false;
});
_scaffoldKey.currentState
.showSnackBar(SnackBar(content: Text('已取消收藏')));
if (ApplicationEvent.event != null) {
ApplicationEvent.event
.fire(CollectionEvent(widget.title, _router, true));
}
return;
}
print('删除错误');
});
} else {
// 插入操作
_collectionControl
.insert(Collection(
name: Uri.encodeComponent(widget.title.trim()),
router: widget.url))
.then((result) {
if (this.mounted) {
setState(() {
_hasCollected = true;
});
if (ApplicationEvent.event != null) {
ApplicationEvent.event
.fire(CollectionEvent(widget.title, _router, false));
}
_scaffoldKey.currentState
.showSnackBar(SnackBar(content: Text('收藏成功')));
}
});
}
}
@override
Widget build(BuildContext context) {
if (_hasCollected) {
_collectionIcons = Icons.favorite;
} else {
_collectionIcons = Icons.favorite_border;
}
return Scaffold(
key: _scaffoldKey,
appBar: AppBar(
title: Text(widget.title),
actions: <Widget>[
new IconButton(
tooltip: 'goBack home',
onPressed: _getCollection,
icon: Icon(
_collectionIcons,
),
),
],
),
body: WebviewScaffold(
url: widget.url,

View File

@ -42,7 +42,6 @@ class SecondPageState extends State<WidgetPage> with AutomaticKeepAliveClientMix
Widget buildGrid() {
// 存放最后的widget
List<Widget> tiles = [];
print("Application.widgetTree>>> ${Application.widgetTree}");
Application.widgetTree.children.forEach((dynamic item) {
tiles.add(new CateCard(category: item));
});

View File

@ -5,105 +5,105 @@ packages:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.5.2"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.2.0"
bloc:
dependency: "direct main"
description:
name: bloc
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.4"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.2"
city_pickers:
dependency: "direct main"
description:
name: city_pickers
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.0.4"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.14.11"
cookie_jar:
dependency: "direct main"
description:
name: cookie_jar
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.1"
csslib:
dependency: transitive
description:
name: csslib
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.16.1"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.2"
dio:
dependency: "direct main"
description:
name: dio
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.13"
event_bus:
dependency: "direct main"
description:
name: event_bus
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
firebase_analytics:
dependency: "direct main"
description:
name: firebase_analytics
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0+1"
firebase_core:
dependency: "direct main"
description:
name: firebase_core
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.4"
fluro:
dependency: "direct main"
description:
name: fluro
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.5.1"
flutter:
@ -115,28 +115,28 @@ packages:
dependency: "direct main"
description:
name: flutter_bloc
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.11.1"
flutter_downloader:
dependency: "direct main"
description:
name: flutter_downloader
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.9"
flutter_jpush:
dependency: "direct main"
description:
name: flutter_jpush
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.0.4"
flutter_spinkit:
dependency: "direct main"
description:
name: flutter_spinkit
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.1.0"
flutter_test:
@ -148,133 +148,133 @@ packages:
dependency: "direct main"
description:
name: flutter_webview_plugin
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.5"
fluttertoast:
dependency: "direct main"
description:
name: fluttertoast
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.1.0"
html:
dependency: "direct main"
description:
name: html
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.14.0+2"
image_picker:
dependency: "direct main"
description:
name: image_picker
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.5.4+3"
intl:
dependency: "direct main"
description:
name: intl
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.15.7"
lpinyin:
dependency: transitive
description:
name: lpinyin
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.7"
markdown:
dependency: "direct main"
description:
name: markdown
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.3"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.5"
meta:
dependency: "direct main"
description:
name: meta
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.6"
open_file:
dependency: "direct main"
description:
name: open_file
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.3"
package_info:
dependency: "direct main"
description:
name: package_info
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.4.0+3"
version: "0.4.0+6"
path:
dependency: "direct main"
description:
name: path
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.6.2"
path_provider:
dependency: "direct main"
description:
name: path_provider
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.7.0"
permission_handler:
dependency: "direct main"
description:
name: permission_handler
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.2.1+1"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.3"
rxdart:
dependency: transitive
description:
name: rxdart
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.21.0"
share:
dependency: "direct main"
description:
name: share
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.6.2"
version: "0.6.2+1"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.4.3"
sky_engine:
@ -286,79 +286,79 @@ packages:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.5.5"
sqflite:
dependency: "direct main"
description:
name: sqflite
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.6+2"
version: "1.1.6+3"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.9.3"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.0"
string_scanner:
dependency: "direct main"
description:
name: string_scanner
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.4"
synchronized:
dependency: transitive
description:
name: synchronized
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0+1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.5"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.6"
url_launcher:
dependency: "direct main"
description:
name: url_launcher
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "5.0.2"
version: "5.1.1"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.8"
sdks:
dart: ">=2.2.2 <3.0.0"
flutter: ">=1.2.1 <2.0.0"
flutter: ">=1.6.0 <2.0.0"