Commit 396c9647 authored by 林生雨's avatar 林生雨

fix album

parent 769772e1
......@@ -3,7 +3,10 @@ package io.flutter.plugins;
import io.flutter.plugin.common.PluginRegistry;
import com.taobao.idlefish.flutterboost.FlutterBoostPlugin;
import com.example.gengmei_flutter_plugin.GengmeiFlutterPlugin;
import io.flutter.plugins.packageinfo.PackageInfoPlugin;
import io.flutter.plugins.pathprovider.PathProviderPlugin;
import io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin;
import com.tekartik.sqflite.SqflitePlugin;
import fleamarket.taobao.com.xservicekit.XserviceKitPlugin;
/**
......@@ -16,7 +19,10 @@ public final class GeneratedPluginRegistrant {
}
FlutterBoostPlugin.registerWith(registry.registrarFor("com.taobao.idlefish.flutterboost.FlutterBoostPlugin"));
GengmeiFlutterPlugin.registerWith(registry.registrarFor("com.example.gengmei_flutter_plugin.GengmeiFlutterPlugin"));
PackageInfoPlugin.registerWith(registry.registrarFor("io.flutter.plugins.packageinfo.PackageInfoPlugin"));
PathProviderPlugin.registerWith(registry.registrarFor("io.flutter.plugins.pathprovider.PathProviderPlugin"));
SharedPreferencesPlugin.registerWith(registry.registrarFor("io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin"));
SqflitePlugin.registerWith(registry.registrarFor("com.tekartik.sqflite.SqflitePlugin"));
XserviceKitPlugin.registerWith(registry.registrarFor("fleamarket.taobao.com.xservicekit.XserviceKitPlugin"));
}
......
......@@ -36,14 +36,5 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.example.gengmei_flutter_plugin"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>
......@@ -5,7 +5,10 @@
#import "GeneratedPluginRegistrant.h"
#import <flutter_boost/FlutterBoostPlugin.h>
#import <gengmei_flutter_plugin/GengmeiFlutterPlugin.h>
#import <package_info/PackageInfoPlugin.h>
#import <path_provider/PathProviderPlugin.h>
#import <shared_preferences/SharedPreferencesPlugin.h>
#import <sqflite/SqflitePlugin.h>
#import <xservice_kit/XserviceKitPlugin.h>
@implementation GeneratedPluginRegistrant
......@@ -13,7 +16,10 @@
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
[FlutterBoostPlugin registerWithRegistrar:[registry registrarForPlugin:@"FlutterBoostPlugin"]];
[GengmeiFlutterPlugin registerWithRegistrar:[registry registrarForPlugin:@"GengmeiFlutterPlugin"]];
[FLTPackageInfoPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTPackageInfoPlugin"]];
[FLTPathProviderPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTPathProviderPlugin"]];
[FLTSharedPreferencesPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTSharedPreferencesPlugin"]];
[SqflitePlugin registerWithRegistrar:[registry registrarForPlugin:@"SqflitePlugin"]];
[XserviceKitPlugin registerWithRegistrar:[registry registrarForPlugin:@"XserviceKitPlugin"]];
}
......
......@@ -19,6 +19,9 @@ Depends on all your plugins, and provides a function to register them.
s.dependency 'Flutter'
s.dependency 'flutter_boost'
s.dependency 'gengmei_flutter_plugin'
s.dependency 'package_info'
s.dependency 'path_provider'
s.dependency 'shared_preferences'
s.dependency 'sqflite'
s.dependency 'xservice_kit'
end
// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=/Users/apple/Downloads/flutter
FLUTTER_APPLICATION_PATH=/Users/apple/lsy/gmalpha_flutter
FLUTTER_TARGET=/Users/apple/lsy/gmalpha_flutter/lib/main.dart
FLUTTER_TARGET=lib/main.dart
FLUTTER_BUILD_DIR=build
SYMROOT=${SOURCE_ROOT}/../build/ios
FLUTTER_BUILD_NAME=1.0.0
FLUTTER_BUILD_NUMBER=1
TRACK_WIDGET_CREATION=true
......@@ -7,7 +7,6 @@
objects = {
/* Begin PBXBuildFile section */
0523E7645C49429140A87BC8 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F32CCBF52B4BC64C019A584D /* libPods-Runner.a */; };
741F496221355F47001E2961 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 741F495E21355F27001E2961 /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
741F496821356857001E2961 /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 741F496521356807001E2961 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
74974048213559DB008C567A /* Release.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 74974046213559DB008C567A /* Release.xcconfig */; };
......@@ -36,8 +35,6 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
2C9B1AB557CD5CBC16164957 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
441FD4625C7D0900F05C9A58 /* 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>"; };
741F495E21355F27001E2961 /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = ../.ios/Flutter/engine/Flutter.framework; sourceTree = "<group>"; };
741F496521356807001E2961 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = ../.ios/Flutter/App.framework; sourceTree = "<group>"; };
74974046213559DB008C567A /* Release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
......@@ -52,8 +49,6 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
F32CCBF52B4BC64C019A584D /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
F99355DD7889C1520E1503E4 /* 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>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -61,21 +56,12 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
0523E7645C49429140A87BC8 /* libPods-Runner.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
37CBF6198D3E34CE197F7E29 /* Frameworks */ = {
isa = PBXGroup;
children = (
F32CCBF52B4BC64C019A584D /* libPods-Runner.a */,
);
name = Frameworks;
sourceTree = "<group>";
};
741F49642135620F001E2961 /* Config */ = {
isa = PBXGroup;
children = (
......@@ -103,8 +89,6 @@
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
F558CDC6611173C14623ADA6 /* Pods */,
37CBF6198D3E34CE197F7E29 /* Frameworks */,
);
sourceTree = "<group>";
};
......@@ -138,16 +122,6 @@
name = "Supporting Files";
sourceTree = "<group>";
};
F558CDC6611173C14623ADA6 /* Pods */ = {
isa = PBXGroup;
children = (
F99355DD7889C1520E1503E4 /* Pods-Runner.debug.xcconfig */,
441FD4625C7D0900F05C9A58 /* Pods-Runner.release.xcconfig */,
2C9B1AB557CD5CBC16164957 /* Pods-Runner.profile.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
......@@ -155,14 +129,12 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
E10CBE561B0B3954E5D8AB2F /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
741F496321355F47001E2961 /* Embed Frameworks */,
5BAC25529DA8134F9EC5F747 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
......@@ -184,7 +156,6 @@
TargetAttributes = {
97C146ED1CF9000F007C117D = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = 86R4V3XFLU;
};
};
};
......@@ -237,24 +208,6 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
};
5BAC25529DA8134F9EC5F747 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../Flutter/engine/Flutter.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
......@@ -269,28 +222,6 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
E10CBE561B0B3954E5D8AB2F /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
......@@ -381,7 +312,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 86R4V3XFLU;
DEVELOPMENT_TEAM = S8QB4VV633;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
......@@ -509,7 +440,6 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 86R4V3XFLU;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
......@@ -534,7 +464,6 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 86R4V3XFLU;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
......@@ -577,6 +506,7 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}
......@@ -4,7 +4,4 @@
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
......@@ -9,5 +9,5 @@ class DirBean {
File pic;
int picCount;
DirBean(this.dirName, this.pic, this.picCount);
DirBean(this.dirName, this.picCount, this.pic);
}
......@@ -54,44 +54,68 @@ class AlbumModel extends BaseModel {
this._selectList.clear();
this._selectList.addAll(selectedList);
}
if (isAndroid) {
_listen = GengmeiFlutterPlugin.phoneImagesEvent
.receiveBroadcastStream()
.listen(_onEvent, onError: _onError);
}
}
void _onEvent(Object event) {
var list = (event as Map)[_nowDirName];
List<ScanImageItem> tempList = new List();
if (list != null && !list.isEmpty) {
for (var item in list) {
ScanImageItem scanImageItem = new ScanImageItem();
scanImageItem.path = item["path"];
scanImageItem.size = item["size"];
scanImageItem.realPath = item["realPath"];
tempList.add(scanImageItem);
var map = (event as Map);
// var list = map[_nowDirName];
_mainValue.forEach((k, itemList) {
for (int i = 0; i < itemList.length; i++) {
if (map[k] == null || map[k][i] == null) {
continue;
}
var newPath = map[k][i]["path"] as String;
if ((itemList[i].path == null || itemList[i].path.isEmpty) &&
newPath != null) {
itemList[i].path = newPath;
}
}
}
albumLive.notifyView(tempList);
});
// var recordList=_mainValue[_nowDirName];
// List<ScanImageItem> tempList = new List();
// if (list != null && !list.isEmpty) {
//// for (int i = 0; i < albumLive.data.length; i++) {
//// if (list[i]["path"] != null) {
//// albumLive.data[i].path = list[i]["path"];
//// }
//// }
// for (var item in list) {
// ScanImageItem scanImageItem = new ScanImageItem();
// scanImageItem.path = item["path"];
// scanImageItem.size = item["size"];
// scanImageItem.realPath = item["realPath"];
// tempList.add(scanImageItem);
// }
// }
// print("EVENTTTT !! ${tempList.length} ${tempList}");
albumLive.notifyView(_mainValue[_nowDirName]);
}
void _onError(Object error) {
print(error);
print("ERROR $error");
}
void initScanImages(BuildContext context) {
if (isAndroid) {
_listen = GengmeiFlutterPlugin.phoneImagesEvent
.receiveBroadcastStream()
.listen(_onEvent, onError: _onError);
}
AlbumRepository.getInstance().scanPhoneImg().listen((value) {
if (value != null) {
_mainValue = value;
value.forEach((key, value) {
if (key == MainDir) {
albumLive.notifyView(value);
titleData.notifyView(MainDirExplain);
_dirList.add(
DirBean(MainDirExplain, File(value[0].path), value.length));
} else {
_dirList.add(DirBean(key, File(value[0].path), value.length));
value.forEach((key, eachValue) {
print("VALUE!!! $eachValue");
if (eachValue != null && !eachValue.isEmpty) {
if (key == MainDir) {
// albumLive.notifyView(eachValue);
titleData.notifyView(MainDirExplain);
_dirList.add(DirBean(
MainDirExplain, eachValue.length, File(eachValue[0].path)));
} else {
_dirList
.add(DirBean(key, eachValue.length, File(eachValue[0].path)));
}
}
});
}
......@@ -158,8 +182,12 @@ class AlbumModel extends BaseModel {
albumLive.notifyView(albumLive.data);
}
void onNext() {
void onNext(BuildContext context) {
if (_selectList.isEmpty) {
Navigator.pop(context, "");
} else {
Navigator.pop(context, _selectList[0]);
}
}
void nativeCamera(BuildContext context) {
......@@ -168,10 +196,12 @@ class AlbumModel extends BaseModel {
return;
}
AlbumRepository.getInstance().nativeCamera().listen((data) {
if (data == null && data.isEmpty) {
print("DATTTTTT ${data}");
if (data == null || data.isEmpty || data == "") {
Toast.show(context, "没有拍摄照片");
} else {
_selectList.add(data);
Navigator.pop(context, data);
// _selectList.add(data);
//TODO
}
}).onError((error) {
......@@ -186,10 +216,11 @@ class AlbumModel extends BaseModel {
return;
}
AlbumRepository.getInstance().aiCamera().listen((data) {
if (data == null && data.isEmpty) {
if (data == null || data.isEmpty || data == "") {
Toast.show(context, "没有拍摄照片");
} else {
_selectList.add(data);
Navigator.pop(context, data);
// _selectList.add(data);
//TODO
}
}).onError((error) {});
......
......@@ -7,7 +7,8 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:gengmei_flutter_plugin/ScanImagePlugn.dart';
import 'package:gmalpha_flutter/AlbumModel/bean/DirBean.dart';
import 'package:gmalpha_flutter/AlbumModel/page/album/AlbumModel.dart';
import 'AlbumModel.dart';
class AlbumPage extends StatefulWidget {
AlbumModel model;
......@@ -31,12 +32,13 @@ class AlbumState extends State<AlbumPage> {
_model.initScanImages(context);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: GestureDetector(
onTap: () => Navigator.pop(context),
onTap: () => Navigator.pop(context, ""),
child: Center(
child: Container(
padding: EdgeInsets.fromLTRB(16, 0, 0, 0),
......@@ -66,9 +68,8 @@ class AlbumState extends State<AlbumPage> {
Container(
margin: EdgeInsets.fromLTRB(1, 0, 0, 0),
child: Transform(
transform: Matrix4.identity()..rotateZ(
_model.showPop?1.6:4.7
), // 旋转的角度
transform: Matrix4.identity()
..rotateZ(_model.showPop ? 1.6 : 4.7), // 旋转的角度
origin: Offset(10, 10), // 旋转的中心点
child: Icon(
Icons.chevron_right,
......@@ -85,7 +86,7 @@ class AlbumState extends State<AlbumPage> {
actions: <Widget>[
Center(
child: GestureDetector(
onTap: () => _model.onNext(),
onTap: () => _model.onNext(context),
child: Container(
margin: EdgeInsets.fromLTRB(0, 0, 16, 0),
child: Text(
......@@ -115,6 +116,7 @@ class AlbumState extends State<AlbumPage> {
initialData: _model.albumLive.data,
builder:
(BuildContext context, AsyncSnapshot<List<ScanImageItem>> imgList) {
print("FINALL $imgList ${imgList.data}");
if (imgList.data == null) {
return Center(child: CircularProgressIndicator());
}
......@@ -174,7 +176,8 @@ class AlbumState extends State<AlbumPage> {
)));
}
int newIndex = index - 2;
if (imgList.data[newIndex] == null) {
if (imgList.data[newIndex] == null ||
imgList.data[newIndex].path == null) {
return Icon(
Icons.photo,
size: 20,
......
......@@ -3,6 +3,6 @@
* @date 2019-09-02
**/
abstract class RouterBaser{
//TODO
}
......@@ -4,6 +4,8 @@
// RouterCenterGenerator
// **************************************************************************
import "package:gmalpha_flutter/PrestigeModel/PrestigeImpl.dart";
import "package:gmalpha_flutter/PrestigeModel/PrestigeRouter.dart";
import "package:gmalpha_flutter/AlbumModel/AlbumRouterImpl.dart";
import "package:gmalpha_flutter/AlbumModel/AlbumRouter.dart";
import "package:gmalpha_flutter/messageModel/MessageRouterImpl.dart";
......@@ -38,6 +40,7 @@ class RouterCenterImpl {
}
void init() {
map.putIfAbsent("prestigeModel", () => PrestigeImpl());
map.putIfAbsent("albumModel", () => AlbumRouterImpl());
map.putIfAbsent("messageModel", () => MessageRouterImpl());
map.putIfAbsent("userModel", () => UserRouterImpl());
......@@ -47,6 +50,13 @@ class RouterCenterImpl {
return map[modelName];
}
PrestigeRouter findPrestigeRouter() {
if (map["prestigeModel"] == null) {
return null;
}
return map["prestigeModel"] as PrestigeRouter;
}
AlbumRouter findAlbumRouter() {
if (map["albumModel"] == null) {
return null;
......
/*
* @author lsy
* @date 2019-09-16
**/
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/PrestigeModel/PrestigeRouter.dart';
import 'package:gmalpha_flutter/PrestigeModel/page/reputation/ReputationsPage.dart';
class PrestigeImpl implements PrestigeRouter{
@override
Widget getReputationsPage(String cookie) {
return ReputationsPage(cookie);
}
}
\ No newline at end of file
/*
* @author lsy
* @date 2019-09-16
**/
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/Annotations/RouterBaser.dart';
import 'package:gmalpha_flutter/Annotations/anno/Router.dart';
import 'package:gmalpha_flutter/PrestigeModel/PrestigeImpl.dart';
@Router("prestigeModel", PrestigeImpl)
abstract class PrestigeRouter implements RouterBaser {
Widget getReputationsPage(String cookie);
}
/*
* @author lsy
* @date 2019-09-16
**/
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/PrestigeModel/service/PrestigeRepository.dart';
import 'package:gmalpha_flutter/PrestigeModel/service/remote/entity/PrestigeEntity.dart';
import 'package:gmalpha_flutter/commonModel/live/BaseModel.dart';
import 'package:gmalpha_flutter/commonModel/live/LiveData.dart';
import 'package:gmalpha_flutter/commonModel/net/DioUtil.dart';
import 'package:gmalpha_flutter/commonModel/toast/toast.dart';
class ReputationsModel extends BaseModel {
LiveData<PrestigeEntity> prestigeLive = new LiveData();
final String cookie;
ReputationsModel(this.cookie);
init(BuildContext context) {
Map<String, dynamic> headMap = new Map();
headMap.putIfAbsent("Cookie", () => cookie);
DioUtil().addHead = headMap;
PrestigeRepository.getInstance().getReputations().listen((value) {
if (value != null) {
prestigeLive.notifyView(value);
}
}).onError((error) {
Toast.show(context, "${error.toString()}");
print(error);
});
}
@override
void dispose() {
prestigeLive.dispost();
}
}
\ No newline at end of file
/*
* @author lsy
* @date 2019-09-16
**/
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/PrestigeModel/page/reputation/ReputationsModel.dart';
import 'package:gmalpha_flutter/PrestigeModel/service/remote/entity/PrestigeEntity.dart';
import 'package:cached_network_image/cached_network_image.dart';
class ReputationsPage extends StatefulWidget {
ReputationsModel _model;
ReputationsPage(String cookie) {
_model = new ReputationsModel(cookie);
}
@override
State<StatefulWidget> createState() => ReputationsState(_model);
}
class ReputationsState extends State<ReputationsPage> {
ReputationsModel _model;
ReputationsState(this._model);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
'我的专家声望',
style: TextStyle(fontSize: 16),
),
centerTitle: true,
leading: IconButton(
// alignment: Alignment.centerLeft,
onPressed: () => Navigator.pop(context),
// padding: EdgeInsets.fromLTRB(22, 0, 0, 0),
icon: Icon(
Icons.keyboard_arrow_left,
),
)),
body: StreamBuilder<PrestigeEntity>(
stream: _model.prestigeLive.stream,
initialData: _model.prestigeLive.data,
builder: (context, data) {
if (data.data == null) {
return loadingItem();
}
if (data.data.error != 0 || data.data.data == null) {
return errorItem(data.data.message);
}
return Column(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(17, 24, 0, 0),
child: MyText(
16.0, data.data.data.introduce[0].question, 0xff323232),
),
Container(
margin: EdgeInsets.fromLTRB(19, 16, 0, 0),
child: MyText(
13.0, data.data.data.introduce[0].answer, 0xff8E8E8E),
),
ListView.builder(
itemCount: data.data.data.reputations.length,
itemBuilder: (context, index) {
return listItem(data, index);
}),
],
);
},
));
}
Widget listItem(AsyncSnapshot<PrestigeEntity> data, int index) {
int allSize = data.data.data.reputations[index].expertTags.length;
int bringSize = 0;
for (var item in data.data.data.reputations[index].expertTags) {
if (item.level > 0) {
bringSize++;
}
}
return Column(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(0, 32, 0, 0),
width: double.maxFinite,
height: 30,
child: Row(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(16, 0, 0, 0),
child: MyText(14.0, data.data.data.reputations[index].category,
0xffffffff),
),
Expanded(
child: Container(),
),
Container(
margin: EdgeInsets.fromLTRB(0, 0, 16, 0),
child: MyText(14.0, "${bringSize}/${allSize}", 0xffffffff),
)
],
),
),
GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3, mainAxisSpacing: 4, crossAxisSpacing: 10.0),
itemBuilder: (context, gridIndex) {
var item =
data.data.data.reputations[index].expertTags[gridIndex];
bool isBright = item.level > 0;
return Column(
children: <Widget>[
isBright
? CachedNetworkImage(imageUrl: item.lightBadge)
: CachedNetworkImage(imageUrl: item.grayBadge),
Container(
margin: EdgeInsets.fromLTRB(0, 5, 0, 0),
child: isBright
? MyText(13.0, "Lv${item.level} ${item.tagName}",
0xff8E8E8E)
: MyText(13.0, "${item.tagName}", 0xffC4C4C4))
],
);
})
],
);
}
Widget errorItem(String reason) {
return Center(
child: Text("$reason"),
);
}
Widget loadingItem() {
return CircularProgressIndicator();
}
Text MyText(double size, String text, int color) {
return Text(
text,
style: TextStyle(fontSize: size, color: Color(color)),
);
}
@override
void dispose() {
super.dispose();
_model.dispose();
}
}
/*
* @author lsy
* @date 2019-09-16
**/
\ No newline at end of file
/*
* @author lsy
* @date 2019-09-16
**/
import 'package:gmalpha_flutter/PrestigeModel/service/local/PresitigeLocal.dart';
import 'package:gmalpha_flutter/PrestigeModel/service/remote/PrestigeRemote.dart';
import 'package:gmalpha_flutter/PrestigeModel/service/remote/entity/PrestigeEntity.dart';
import 'package:rxdart/rxdart.dart';
class PrestigeRepository {
PrestigeRemote _remote;
PresitigeLocal _local;
static PrestigeRepository _userRepository;
PrestigeRepository._() {
_remote = PrestigeRemote.getInstance();
_local = PresitigeLocal.getInstance();
}
static PrestigeRepository getInstance() {
if (_userRepository == null) {
_userRepository = PrestigeRepository._();
}
return _userRepository;
}
Observable<PrestigeEntity> getReputations() {
return _remote.getReputations().map((value) {
if (value != null) {
}
return value;
});
}
}
/*
* @author lsy
* @date 2019-09-16
**/
class PresitigeLocal {
static PresitigeLocal _userRemote;
PresitigeLocal._() {}
static PresitigeLocal getInstance() {
if (_userRemote == null) {
_userRemote = new PresitigeLocal._();
}
return _userRemote;
}
}
/*
* @author lsy
* @date 2019-09-16
**/
import 'package:gmalpha_flutter/PrestigeModel/service/remote/api/PrestigeApi.serv.dart';
import 'package:gmalpha_flutter/PrestigeModel/service/remote/entity/PrestigeEntity.dart';
import 'package:rxdart/rxdart.dart';
class PrestigeRemote {
static PrestigeRemote _userRemote;
PrestigeRemote._() {}
static PrestigeRemote getInstance() {
if (_userRemote == null) {
_userRemote = new PrestigeRemote._();
}
return _userRemote;
}
Observable<PrestigeEntity> getReputations() {
return PrestigeApiImpl().getReputations();
}
}
/*
* @author lsy
* @date 2019-09-16
**/
import 'package:gmalpha_flutter/Annotations/anno/Get.dart';
import 'package:gmalpha_flutter/Annotations/anno/Query.dart';
import 'package:gmalpha_flutter/Annotations/anno/ServiceCenter.dart';
import 'package:gmalpha_flutter/PrestigeModel/service/remote/entity/PrestigeEntity.dart';
@ServiceCenter()
abstract class PrestigeApi{
@Get("api/v1/reputations")
PrestigeEntity getReputations();
}
\ No newline at end of file
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// ServiceGenerator
// **************************************************************************
import 'dart:convert';
import 'dart:io';
import 'package:rxdart/rxdart.dart';
import 'package:gmalpha_flutter/PrestigeModel/service/remote/entity/PrestigeEntity.dart';
import 'package:gmalpha_flutter/commonModel/net/DioUtil.dart';
class PrestigeApiImpl {
factory PrestigeApiImpl() => _sharedInstance();
static PrestigeApiImpl _instance;
PrestigeApiImpl._() {}
static PrestigeApiImpl _sharedInstance() {
if (_instance == null) {
_instance = PrestigeApiImpl._();
}
return _instance;
}
Observable<PrestigeEntity> getReputations() {
return Observable.fromFuture(DioUtil().get('api/v1/reputations'))
.map((value) {
if (value.statusCode == 200) {
Map map = json.decode(value.toString());
return PrestigeEntity.fromJson(map);
} else {
throw HttpException("statusCode error :${value.statusCode}");
}
});
}
}
/*
* @author lsy
* @date 2019-09-16
**/
class PrestigeEntity {
int error;
String message;
Null extra;
Data data;
PrestigeEntity({this.error, this.message, this.extra, this.data});
PrestigeEntity.fromJson(Map<String, dynamic> json) {
error = json['error'];
message = json['message'];
extra = json['extra'];
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['error'] = this.error;
data['message'] = this.message;
data['extra'] = this.extra;
if (this.data != null) {
data['data'] = this.data.toJson();
}
return data;
}
}
class Data {
List<Introduce> introduce;
List<Reputations> reputations;
Data({this.introduce, this.reputations});
Data.fromJson(Map<String, dynamic> json) {
if (json['introduce'] != null) {
introduce = new List<Introduce>();
json['introduce'].forEach((v) {
introduce.add(new Introduce.fromJson(v));
});
}
if (json['reputations'] != null) {
reputations = new List<Reputations>();
json['reputations'].forEach((v) {
reputations.add(new Reputations.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.introduce != null) {
data['introduce'] = this.introduce.map((v) => v.toJson()).toList();
}
if (this.reputations != null) {
data['reputations'] = this.reputations.map((v) => v.toJson()).toList();
}
return data;
}
}
class Introduce {
String question;
String answer;
Introduce({this.question, this.answer});
Introduce.fromJson(Map<String, dynamic> json) {
question = json['question'];
answer = json['answer'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['question'] = this.question;
data['answer'] = this.answer;
return data;
}
}
class Reputations {
String category;
List<ExpertTags> expertTags;
Reputations({this.category, this.expertTags});
Reputations.fromJson(Map<String, dynamic> json) {
category = json['category'];
if (json['expert_tags'] != null) {
expertTags = new List<ExpertTags>();
json['expert_tags'].forEach((v) {
expertTags.add(new ExpertTags.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['category'] = this.category;
if (this.expertTags != null) {
data['expert_tags'] = this.expertTags.map((v) => v.toJson()).toList();
}
return data;
}
}
class ExpertTags {
int tagId;
String tagName;
String grayBadge;
String lightBadge;
int level;
ExpertTags(
{this.tagId, this.tagName, this.grayBadge, this.lightBadge, this.level});
ExpertTags.fromJson(Map<String, dynamic> json) {
tagId = json['tag_id'];
tagName = json['tag_name'];
grayBadge = json['gray_badge'];
lightBadge = json['light_badge'];
level = json['level'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['tag_id'] = this.tagId;
data['tag_name'] = this.tagName;
data['gray_badge'] = this.grayBadge;
data['light_badge'] = this.lightBadge;
data['level'] = this.level;
return data;
}
}
\ No newline at end of file
......@@ -174,7 +174,6 @@ class _CommentSuggestPageState extends State<CommentSuggestPage> {
BaseOptions options = DioUtil.getDefOptions();
final cookie = new Map<String, dynamic>.from(widget.nativeCookie);
HttpConfig config = new HttpConfig(options: options, nativeCookie: cookie);
DioUtil.openDebug();
DioUtil().setConfig(config);
String content = (this.opinionCtrl.text.length > 0)? this.opinionCtrl.text : '';
String phone = (this.telCtrl.text.length > 0)? this.telCtrl.text : '';
......
/*
* @author lsy
* @date 2019-09-16
**/
/**
* 生产环境
*/
const String APP_HOST_RELEASE = "https://earth.iyanzhi.com";
/**
* 测试环境
*/
const String APP_HOST_DEBUG = "http://earth.gmapp.env";
/**
* 开发环境
*/
const String APP_HOST_DEV = "http://earth.alpha.newdev";
class Api{
}
\ No newline at end of file
import 'dart:convert';
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:gmalpha_flutter/commonModel/net/Api.dart';
import 'package:gmalpha_flutter/commonModel/toast/toast.dart';
import 'package:package_info/package_info.dart';
const bool inProduction = const bool.fromEnvironment("dart.vm.product");
/// <BaseResp<T> 返回 status code msg data.
class BaseResp<T> {
......@@ -151,8 +157,10 @@ class DioUtil {
String _proxy = '172.30.9.117:8888';
Map<String, dynamic> addHeadMap;
/// 是否是debug模式.
static bool _isDebug = true;
static bool _isDebug = !inProduction;
static DioUtil getInstance() {
return _instance;
......@@ -164,26 +172,48 @@ class DioUtil {
DioUtil._init() {
_dio = new Dio(_options);
initDeviceInfo().then((value) {
_dio.interceptors
.add(InterceptorsWrapper(onRequest: (RequestOptions options) {
//TODO fix it
var queryParameters = options.queryParameters;
queryParameters.putIfAbsent("app_name", () => value.packageName);
queryParameters.putIfAbsent("version", () => value.version);
queryParameters.putIfAbsent(
"platform", () => Platform.isIOS ? "ios" : "android");
var headers = options.headers;
if (addHeadMap != null) {
addHeadMap.forEach((k, v) {
headers.putIfAbsent(k, () => v);
});
}
print("请求之前");
// Do something before request is sent
return options; //continue
}, onResponse: (Response response) {
print("响应之前");
// Do something with response data
return response; // continue
}, onError: (DioError e) {
print("错误之前");
// Do something with response error
return e; //continue
}));
}).catchError((error) {
print(error);
});
//TODO
_dio.interceptors
.add(InterceptorsWrapper(onRequest: (RequestOptions options) {
print("请求之前");
// Do something before request is sent
return options; //continue
}, onResponse: (Response response) {
print("响应之前");
// Do something with response data
return response; // continue
}, onError: (DioError e) {
print("错误之前");
// Do something with response error
return e; //continue
}));
}
/// 打开debug模式.
static void openDebug() {
_isDebug = true;
set addHead(Map<String, dynamic> map) {
if (map != null) {
addHeadMap = map;
}
}
Future<PackageInfo> initDeviceInfo() async {
return await PackageInfo.fromPlatform();
}
/// set Config.
......@@ -197,36 +227,36 @@ class DioUtil {
_pem = config.pem ?? _pem;
if (_dio != null) {
_dio.options = _options;
// _dio.options = _options;
// (_dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (client) {
// client.findProxy = (url) {
// return _isDebug ? 'PROXY $_proxy' : 'DIRECT';
// };
// };
// if (_pem != null) {
// // httpClientAdapter
// (_dio.httpClientAdapter as DefaultHttpClientAdapter)
// .onHttpClientCreate = (client) {
// client.badCertificateCallback =
// (X509Certificate cert, String host, int port) {
// if (cert.pem == _pem) {
// // 证书一致,则放行
// return true;
// }
// return false;
// };
// };
// }
// if (_pKCSPath != null) {
// (_dio.httpClientAdapter as DefaultHttpClientAdapter)
// .onHttpClientCreate = (client) {
// SecurityContext sc = new SecurityContext();
// //file为证书路径
// sc.setTrustedCertificates(_pKCSPath, password: _pKCSPwd);
// HttpClient httpClient = new HttpClient(context: sc);
// return httpClient;
// };
// }
if (_pem != null) {
// httpClientAdapter
(_dio.httpClientAdapter as DefaultHttpClientAdapter)
.onHttpClientCreate = (client) {
client.badCertificateCallback =
(X509Certificate cert, String host, int port) {
if (cert.pem == _pem) {
// 证书一致,则放行
return true;
}
return false;
};
};
}
if (_pKCSPath != null) {
(_dio.httpClientAdapter as DefaultHttpClientAdapter)
.onHttpClientCreate = (client) {
SecurityContext sc = new SecurityContext();
//file为证书路径
sc.setTrustedCertificates(_pKCSPath, password: _pKCSPwd);
HttpClient httpClient = new HttpClient(context: sc);
return httpClient;
};
}
}
}
......@@ -547,6 +577,26 @@ class DioUtil {
return dio;
}
static String getBaseUrl() {
if (inProduction) {
//正式环境的
// String myDomain = getDomain();
// if (myDomain!=null){
// return myDomain;
// }
return APP_HOST_RELEASE;
} else {
// if (BuildConfig.isDevelop) {
// //开发环境的
// return Api.APP_HOST_DEV;
// } else {
// //测试环境
// return TextUtils.isEmpty(customWebHost) ? Api.APP_HOST_DEBUG : customWebHost;
// }
return APP_HOST_DEBUG;
}
}
/// get Def Options.
static BaseOptions getDefOptions() {
BaseOptions options = BaseOptions();
......@@ -557,7 +607,7 @@ class DioUtil {
options.responseType = ResponseType.plain;
// options.baseUrl = 'https://earth.iyanzhi.com/';
// options.baseUrl = 'http://earth.gmapp.env/';
options.baseUrl = "https://www.wanandroid.com/";
options.baseUrl = getBaseUrl() + "/";
Map<String, dynamic> headers = Map<String, dynamic>();
headers['Accept'] = 'application/json';
headers['version'] = '1.0.0';
......
......@@ -25,27 +25,20 @@ class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
_init();
FlutterBoost.singleton.registerPageBuilders({
'comment_suggest': (pageName, params, _) => CommentSuggest(params),
'message_home': (pageName, params, _) => MessageHomePage(params),
'album': (pageName, params, _) {
var param = params["needCamera"];
var param1 = params["aa"];
var param2 = params["ww"];
return RouterCenterImpl().findAlbumRouter().getAlbumPage(param, param1, param2);
}
});
FlutterBoost.handleOnStartPage();
}
void _init() {
BaseOptions options = DioUtil.getDefOptions();
Map<String, dynamic> cookie = {
'cookie':
'_gm_token=1987651565078867; _gtid=7b19ca1cb4d511e9bf97525400e82fab4241; sessionid=d45sucgkl5frearp8qoezpjio65z8svh;'
};
HttpConfig config = new HttpConfig(options: options, nativeCookie: cookie);
DioUtil().setConfig(config);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
......@@ -62,7 +55,8 @@ class _MyAppState extends State<MyApp> {
// }
// return findMessageRouter.getMessagePage({});
// return RouterCenterImpl().findUserRouter()?.getUserPage();
return RouterCenterImpl().findAlbumRouter().getAlbumPage(true, 9, null);
// return RouterCenterImpl().findAlbumRouter().getAlbumPage(true, 9, null);
return RouterCenterImpl().findPrestigeRouter()?.getReputationsPage("sessionid=9odo0sov71x66ke9dlphibnq9i9gduxj; _gtid=3fbe9b78d2cb11e98bc1525400e82fab5270; _gm_token=db88861568285036");
// var findUserRouter = RouterCenterImpl().findUserRouter();
// if(findUserRouter==null){
// return null;
......
......@@ -85,6 +85,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "6.6.0"
cached_network_image:
dependency: "direct main"
description:
name: cached_network_image
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.1"
charcode:
dependency: transitive
description:
......@@ -174,6 +181,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.0.420"
flutter_cache_manager:
dependency: transitive
description:
name: flutter_cache_manager
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.1"
flutter_test:
dependency: "direct dev"
description: flutter
......@@ -298,6 +312,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.5"
package_info:
dependency: "direct main"
description:
name: package_info
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.4.0+6"
package_resolver:
dependency: transitive
description:
......@@ -312,6 +333,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.6.2"
path_provider:
dependency: transitive
description:
name: path_provider
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.0"
pedantic:
dependency: transitive
description:
......@@ -319,6 +347,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.7.0"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.2.1"
pool:
dependency: transitive
description:
......@@ -401,6 +436,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.5.5"
sqflite:
dependency: transitive
description:
name: sqflite
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.6+4"
stack_trace:
dependency: transitive
description:
......@@ -429,6 +471,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.4"
synchronized:
dependency: transitive
description:
name: synchronized
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0+1"
term_glyph:
dependency: transitive
description:
......@@ -457,6 +506,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.6"
uuid:
dependency: transitive
description:
name: uuid
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.2"
vector_math:
dependency: transitive
description:
......@@ -494,4 +550,4 @@ packages:
version: "2.1.16"
sdks:
dart: ">=2.3.0-dev.0.1 <3.0.0"
flutter: ">=0.1.4 <2.0.0"
flutter: ">=1.5.0 <2.0.0"
......@@ -35,6 +35,8 @@ dependencies:
# mmkv_flutter: ^1.0.10
flutter_boost: ^0.0.411
gengmei_flutter_plugin: ^0.0.713
package_info: ^0.4.0+2
cached_network_image: ^1.1.1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment