Merge pull request #63 from Nealyang/master

fix:collection bug
This commit is contained in:
一凨
2019-01-23 11:19:27 +08:00
committed by GitHub
4 changed files with 7 additions and 10 deletions

View File

@ -8,7 +8,6 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
333E5DAE7FC10AC69FEC26C0 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DDA792F029EDD7A11295D192 /* libPods-Runner.a */; }; 333E5DAE7FC10AC69FEC26C0 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DDA792F029EDD7A11295D192 /* libPods-Runner.a */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
@ -40,7 +39,6 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; }; 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
@ -90,7 +88,6 @@
9740EEB11CF90186004384FC /* Flutter */ = { 9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
3B80C3931E831B6300D905FE /* App.framework */, 3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9740EEBA1CF902C7004384FC /* Flutter.framework */, 9740EEBA1CF902C7004384FC /* Flutter.framework */,
@ -210,7 +207,6 @@
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;

View File

@ -50,7 +50,6 @@ class CollectionControlModel {
List list = await sql.getByCondition(); List list = await sql.getByCondition();
List<CollectionGeneral> resultList = []; List<CollectionGeneral> resultList = [];
list.forEach((item){ list.forEach((item){
print(item);
resultList.add(CollectionGeneral.fromJSON(item)); resultList.add(CollectionGeneral.fromJSON(item));
}); });
return resultList; return resultList;

View File

@ -104,7 +104,7 @@ class _CollectionPageState extends State<CollectionPage> {
color: Theme.of(context).primaryColor, color: Theme.of(context).primaryColor,
), ),
title: Text( title: Text(
_collectionList[index - 1].name, Uri.decodeComponent(_collectionList[index - 1].name),
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 17.0), style: TextStyle(fontSize: 17.0),
), ),
@ -112,8 +112,9 @@ class _CollectionPageState extends State<CollectionPage> {
Icon(Icons.keyboard_arrow_right, color: Colors.grey, size: 30.0), Icon(Icons.keyboard_arrow_right, color: Colors.grey, size: 30.0),
onTap: () { onTap: () {
if (_collectionList[index - 1].router.contains('http')) { if (_collectionList[index - 1].router.contains('http')) {
// 注意这里title已经转义过了
Application.router.navigateTo(context, Application.router.navigateTo(context,
'${Routes.webViewPage}?title=${Uri.encodeComponent(_collectionList[index - 1].name)}&url=${Uri.encodeComponent(_collectionList[index - 1].router)}'); '${Routes.webViewPage}?title=${_collectionList[index - 1].name}&url=${Uri.encodeComponent(_collectionList[index - 1].router)}');
} else { } else {
Application.router Application.router
.navigateTo(context, "${_collectionList[index - 1].router}"); .navigateTo(context, "${_collectionList[index - 1].router}");

View File

@ -10,6 +10,7 @@ import '../model/collection.dart';
import '../event/event-bus.dart'; import '../event/event-bus.dart';
import '../event/event-model.dart'; import '../event/event-model.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluttertoast/fluttertoast.dart';
import 'dart:core';
class WebViewPage extends StatefulWidget { class WebViewPage extends StatefulWidget {
final String url; final String url;
@ -38,7 +39,7 @@ class _WebViewPageState extends State<WebViewPage> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_collectionControl.getRouterByName(widget.title.trim()).then((list) { _collectionControl.getRouterByName(Uri.encodeComponent(widget.title.trim())).then((list) {
list.forEach((item) { list.forEach((item) {
if(widget.title.trim() == item['name']){ if(widget.title.trim() == item['name']){
@ -57,7 +58,7 @@ class _WebViewPageState extends State<WebViewPage> {
_getCollection() { _getCollection() {
if (_hasCollected) { if (_hasCollected) {
// 删除操作 // 删除操作
_collectionControl.deleteByName(widget.title.trim()).then((result) { _collectionControl.deleteByName(Uri.encodeComponent(widget.title.trim())).then((result) {
if (result > 0 && this.mounted) { if (result > 0 && this.mounted) {
setState(() { setState(() {
_hasCollected = false; _hasCollected = false;
@ -75,7 +76,7 @@ class _WebViewPageState extends State<WebViewPage> {
} else { } else {
// 插入操作 // 插入操作
_collectionControl _collectionControl
.insert(Collection(name: widget.title.trim(), router: widget.url)) .insert(Collection(name:Uri.encodeComponent(widget.title.trim()) , router: widget.url))
.then((result) { .then((result) {
if (this.mounted) { if (this.mounted) {
setState(() { setState(() {