From 0c0262d29b8ded7364a1d67de8195d27f4cdf6ca Mon Sep 17 00:00:00 2001 From: hackycy Date: Mon, 6 Jul 2020 18:27:48 +0800 Subject: [PATCH] =?UTF-8?q?styles=EF=BC=9AOptimization=20of=20QR=20code=20?= =?UTF-8?q?configuration=20and=20transformation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pb_setting_page/pb_setting_page.dart | 11 +-------- .../pb_setting_page/pb_setting_presenter.dart | 24 +++++-------------- 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/lib/views/pb_setting_page/pb_setting_page.dart b/lib/views/pb_setting_page/pb_setting_page.dart index 60a80d8..6c91aaf 100644 --- a/lib/views/pb_setting_page/pb_setting_page.dart +++ b/lib/views/pb_setting_page/pb_setting_page.dart @@ -99,16 +99,7 @@ class _PBSettingPageState extends State if (status == PermissionStatus.granted) { var result = await BarcodeScanner.scan(); if (result.type == ResultType.Barcode) { - showDialog( - context: context, - builder: (context) { - return NetLoadingDialog( - loading: true, - outsideDismiss: false, - loadingText: '转换中...', - requestCallBack: _presenter.doTransferJson(result.rawContent), - ); - }); + _presenter.doTransferJson(result.rawContent); } } else { PermissionUtils.showPermissionDialog(context); diff --git a/lib/views/pb_setting_page/pb_setting_presenter.dart b/lib/views/pb_setting_page/pb_setting_presenter.dart index 8e1dc64..53339a8 100644 --- a/lib/views/pb_setting_page/pb_setting_presenter.dart +++ b/lib/views/pb_setting_page/pb_setting_presenter.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_picgo/model/gitee_config.dart'; import 'package:flutter_picgo/model/github_config.dart'; import 'package:flutter_picgo/model/pb_setting.dart'; +import 'package:flutter_picgo/model/qiniu_config.dart'; import 'package:flutter_picgo/model/smms_config.dart'; import 'package:flutter_picgo/resources/pb_type_keys.dart'; import 'package:flutter_picgo/utils/image_upload.dart'; @@ -41,24 +42,11 @@ class PBSettingPagePresenter { /// transfer picgo json config to flutter-picgo doTransferJson(String jsonStr) async { try { - var map = json.decode(jsonStr); - // decode github - if (map[PBTypeKeys.github] != null) { - var githubConfig = - json.encode(GithubConfig.fromJson(map[PBTypeKeys.github])); - await ImageUploadUtils.savePBConfig(PBTypeKeys.github, githubConfig); - } - // decode smms - if (map[PBTypeKeys.smms] != null) { - var smmsConfig = json.encode(SMMSConfig.fromJson(map[PBTypeKeys.smms])); - await ImageUploadUtils.savePBConfig(PBTypeKeys.smms, smmsConfig); - } - - if (map[PBTypeKeys.gitee] != null) { - var giteeConfig = - json.encode(GiteeConfig.fromJson(map[PBTypeKeys.gitee])); - await ImageUploadUtils.savePBConfig(PBTypeKeys.gitee, giteeConfig); - } + Map map = json.decode(jsonStr); + map.forEach((key, value) async { + var config = json.encode(value); + await ImageUploadUtils.savePBConfig(key, config); + }); // success _view.transferSuccess(); } catch (e) {