Skip to content

Commit

Permalink
V3.0:
Browse files Browse the repository at this point in the history
* 使用GetConnect搭建网络访问框架,使用baseResponse进行结果解析
* 接口返回的结果,使用https://caijinglong.github.io/json2dart/index.html快速生成,放到models包中
* 登陆注册界面及功能完成
* 登陆/注册之后的Cookie数据保存到SharedPreference中,在接口请求前,读取SharedPreference中到Cookie数据
* 导入google的UI Kit工具库
* 删除之前到flutter_zoom_drawer,使用google自带的drawer
* 列表项需要缓存,只需要使用 KeepAliveWrapper包裹,防止多次加载
  • Loading branch information
PGzxc committed May 28, 2022
1 parent fc0233e commit 44d4c43
Show file tree
Hide file tree
Showing 158 changed files with 12,420 additions and 235 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,26 @@
### v2.0
* 添加设置页面
* 添加切换主题和语言功能
* 添加shared_preferences后直接运行会出错,通过flutter run指令运行
* 添加shared_preferences工具库

### v3.0
* 使用GetConnect搭建网络访问框架,使用baseResponse进行结果解析
* 接口返回的结果,使用https://caijinglong.github.io/json2dart/index.html快速生成,放到models包中
* 登陆注册界面及功能完成
* 登陆/注册之后的Cookie数据保存到SharedPreference中,在接口请求前,读取SharedPreference中到Cookie数据
* 导入google的UI Kit工具库
* 删除之前到flutter_zoom_drawer,使用google自带的drawer
* 列表项需要缓存,只需要使用 KeepAliveWrapper包裹,防止多次加载

## 五 开源库
* Getx:https://github.com/jonataslaw/getx
* logger: https://pub:flutter-io:cn/packages/logger
* flutter_zoom_drawer:https://pub.flutter-io.cn/packages/flutter_zoom_drawer
* shared_preferences:https://pub.flutter-io.cn/packages/shared_preferences
* connectivity_plus:https://pub.flutter-io.cn/packages/connectivity_plus
* json_annotation、json_serializable、build_runner:
* flutter_easyloading:https://pub.flutter-io.cn/packages/flutter_easyloading
* getwidget:https://pub.flutter-io.cn/packages/getwidget



Expand Down
3 changes: 2 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@ flutter {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
//implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
6 changes: 6 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.flutter_wanandroid">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>

<application
android:label="flutter_wanandroid"
android:name="${applicationName}"
Expand Down
13 changes: 13 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
PODS:
- connectivity_plus (0.0.1):
- Flutter
- ReachabilitySwift
- Flutter (1.0.0)
- ReachabilitySwift (5.0.0)
- shared_preferences_ios (0.0.1):
- Flutter

DEPENDENCIES:
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
- Flutter (from `Flutter`)
- shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`)

SPEC REPOS:
trunk:
- ReachabilitySwift

EXTERNAL SOURCES:
connectivity_plus:
:path: ".symlinks/plugins/connectivity_plus/ios"
Flutter:
:path: Flutter
shared_preferences_ios:
:path: ".symlinks/plugins/shared_preferences_ios/ios"

SPEC CHECKSUMS:
connectivity_plus: 413a8857dd5d9f1c399a39130850d02fe0feaf7e
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
shared_preferences_ios: 548a61f8053b9b8a49ac19c1ffbc8b92c50d68ad

PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
Expand Down
14 changes: 14 additions & 0 deletions lib/config/api_provider_config.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:flutter_wanandroid/provider/api_provider.dart';
import 'package:get/get.dart';

class APIProviderConfig extends GetxService {

Future<APIProviderConfig> init() async {
Get.put(ApiProvider());
return this;
}

ApiProvider getAPiProvider() {
return Get.find<ApiProvider>();
}
}
3 changes: 0 additions & 3 deletions lib/config/get_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ class GetConfig extends GetxService{
defaultTransition: Transition.leftToRightWithFade,
logWriterCallback: localLogWriter,
);
const GetMaterialApp(
debugShowCheckedModeBanner: false,
);
await Get.putAsync(()=>SharedPreferences.getInstance());
return this;
}
Expand Down
34 changes: 30 additions & 4 deletions lib/config/global_config.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_wanandroid/config/api_provider_config.dart';
import 'package:flutter_wanandroid/config/get_config.dart';
import 'package:flutter_wanandroid/pages/login_register/utils/login_register_utils.dart';
import 'package:flutter_wanandroid/provider/base_controller.dart';
import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';

import '../pages/theme/utils/theme_util.dart';

class Config {
static const isDebug = true;
Expand All @@ -15,10 +20,31 @@ class Config {
statusBarIconBrightness: Brightness.dark,
),
);

///Get配置
await Get.putAsync(() => GetConfig().init());
//Get.put(() => AppDrawerController());
///SharedPreference配置
//await Get.putAsync(()=>SharedPreferences.getInstance());
await Get.putAsync(() => APIProviderConfig().init());

///是否登陆-用于退出重新进入时判断是否登陆
LoginRegisterUtils().isLogin = LoginRegisterUtils.getUserInfo() != null;
//BaseController().isLogin=LoginRegisterUtils.getUserInfo()!=null;

///配置EasyLoading
// EasyLoading.instance
// ..displayDuration = const Duration(seconds: 1)
// ..indicatorType = EasyLoadingIndicatorType.fadingCircle
// ..loadingStyle = ThemeUtil.getThemeModel() == ThemeData.dark()
// ? EasyLoadingStyle.light
// : EasyLoadingStyle.dark
// ..indicatorSize = 45.0
// ..radius = 10.0
// ..progressColor = Colors.transparent
// ..backgroundColor = Colors.transparent
// ..indicatorColor = Colors.transparent
// ..textColor = Colors.transparent
// ..maskColor = Colors.white.withOpacity(0.5)
// ..userInteractions = true
// ..dismissOnTap = false;
}

}
47 changes: 44 additions & 3 deletions lib/i18n/i18n_en.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter_wanandroid/i18n/i18n_keys.dart';
import 'package:get/get.dart';

class I18nEn {
static const enKey = 'en_US';
Expand All @@ -16,8 +17,48 @@ class I18nEn {
Keys.usEnglish: 'US',
Keys.lightTheme: 'Light Theme',
Keys.darkTheme: 'Dark Theme',
Keys.accountSafe:'Account Safe',
Keys.personInfo:'Person Info',
Keys.setting:'Setting',
Keys.menuUnLogin:'Un Login',
Keys.menuTodoList: 'TODO List',
Keys.menuUnreadMsg: 'UnRead Msg',
Keys.menuWenDa: 'Wen Da',


Keys.welcomeLoginContent:'Hi,Welcome Login',
Keys.welcomeRegisterContent:'Hi,Welcome Register',
Keys.loginContent: "Login",
Keys.registerContent: "Register",
Keys.logoutContent: "Log out",



Keys.editUserNameHint: "Please enter user name",
Keys.editPasswordHint: "Please enter your password",
Keys.editEnsurePasswordHint: "Please enter your password again",
Keys.switchButtonLoginDesc: "Have an account, log in",
Keys.switchButtonRegisterDesc: "Not have an account, sign up",
Keys.loginRegisterInfo: "Log in once the account is successfully registered",
Keys.userNameEmptyInfo: 'The user name cannot be empty~',
Keys.passwordEmptyInfo: "The password cannot be empty~",
Keys.ensurePasswordEmptyInfo: "Confirm password cannot be empty~",
Keys.ensurePasswordFail: "The entered passwords are inconsistent!",


Keys.meLevel:'Level',
Keys.meRank:'Rank',
Keys.meCoin:'Coin',
Keys.meCollect:'Collect',
Keys.meUnLoginTitle:'Welcome to Login',
Keys.meLoginTitle:'Hello',
Keys.meCommonTools:'Common Tools',
Keys.meTools:'Tools',
Keys.meQA:'Q&A',
Keys.meMsg:'Message',
Keys.meCourse:'Course',
Keys.meToDo:'ToDo',
Keys.meShareArticle:'Share Article',
Keys.meShareProject:'Share Project',
Keys.meWechat:'Wechat',


};
}
45 changes: 42 additions & 3 deletions lib/i18n/i18n_keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,46 @@ abstract class Keys {
static const String usEnglish = 'us';

///Menu
static const String accountSafe = 'accountSafe';
static const String personInfo = 'personInfo';
static const String setting = 'setting';
static const String menuUnLogin='unLogin';
static const String menuTodoList = 'todoList';
static const String menuUnreadMsg = 'unreadMsg';
static const String menuWenDa = 'WenDa';

///登陆与注册
static const String welcomeLoginContent = 'welcomeLoginContent';
static const String welcomeRegisterContent = 'welcomeRegisterContent';
static const String loginContent = 'loginContent';
static const String registerContent = 'registerContent';
static const String logoutContent = 'logoutContent';

static const String editUserNameHint = 'editUserNameHint';
static const String editPasswordHint = 'editPasswordHint';
static const String editEnsurePasswordHint = 'editEnsurePasswordHint';
static const String switchButtonLoginDesc = 'switchButtonLoginDesc';
static const String switchButtonRegisterDesc = 'switchButtonRegisterDesc';
static const String loginRegisterInfo = 'loginRegisterInfo';
static const String userNameEmptyInfo = 'userNameEmptyInfo';
static const String passwordEmptyInfo = 'passwordEmptyInfo';
static const String ensurePasswordEmptyInfo = 'ensurePasswordEmptyInfo';
static const String ensurePasswordFail = 'ensurePasswordFail';

///Me-信息
static const String meLevel = 'meLevel';
static const String meRank = 'meRank';
static const String meCollect = 'meCollect';
static const String meCoin = 'meCoin';

static const String meUnLoginTitle='UnLoginTitle';
static const String meLoginTitle='LoginTitle';
static const String meCommonTools='CommonTools';
static const String meTools='Tools';
static const String meQA='QA';
static const String meMsg='Message';
static const String meCourse='Course';
static const String meToDo='ToDo';
static const String meShareArticle='shareArticle';
static const String meShareProject='shareProject';
static const String meWechat='wechat';


}
45 changes: 40 additions & 5 deletions lib/i18n/i18n_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,46 @@ class I18nZH {
Keys.systemMode: '跟随系统',
Keys.simpleChinese: '简体中文',
Keys.usEnglish: '英语',
Keys.lightTheme:'日间模式',
Keys.darkTheme:'夜间模式',
Keys.accountSafe:'账号安全',
Keys.personInfo:'个人信息',
Keys.setting:'设置'
Keys.lightTheme: '日间模式',
Keys.darkTheme: '夜间模式',
Keys.menuUnLogin:'未登录',
Keys.menuTodoList: '待办事项',
Keys.menuUnreadMsg: '未读消息',
Keys.menuWenDa: '问答',

Keys.welcomeLoginContent:'你好,欢迎登陆',
Keys.welcomeRegisterContent:'你好,欢迎注册',
Keys.loginContent: "登录",
Keys.registerContent: "注册",
Keys.logoutContent: "退出登录",


Keys.editUserNameHint: "请输入用户名",
Keys.editPasswordHint: "请输入密码",
Keys.editEnsurePasswordHint: '请再次输入密码',
Keys.switchButtonLoginDesc: '已有账号,去登录',
Keys.switchButtonRegisterDesc: '没有账号,去注册',
Keys.loginRegisterInfo: '注册账号成功即登录',
Keys.userNameEmptyInfo: '用户名不能为空~',
Keys.passwordEmptyInfo: '密码不能为空~',
Keys.ensurePasswordEmptyInfo: '确认密码不能为空~',
Keys.ensurePasswordFail: '两次输入的密码不一致!',


Keys.meLevel:'等级',
Keys.meRank:'排名',
Keys.meCoin:'积分',
Keys.meCollect:'收藏',
Keys.meUnLoginTitle:'欢迎登陆',
Keys.meLoginTitle:'您好!',
Keys.meCommonTools:'常用功能',
Keys.meTools:'工具',
Keys.meQA:'问答',
Keys.meMsg:'消息',
Keys.meCourse:'课程',
Keys.meToDo:'待办清单',
Keys.meShareArticle:'分享文章',
Keys.meShareProject:'分享项目',
Keys.meWechat:'公众号',
};
}
6 changes: 4 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_wanandroid/config/global_config.dart';
import 'package:flutter_wanandroid/pages/language/utils/language_util.dart';
import 'package:flutter_wanandroid/pages/theme/utils/theme_util.dart';
Expand All @@ -17,7 +18,6 @@ Future<void> main() async {
await Config.init();
runApp(GetMaterialApp(
debugShowCheckedModeBanner: false,

unknownRoute: AppPages.unknownRoute,
initialRoute: AppPages.init,
getPages: AppPages.routes,
Expand All @@ -26,10 +26,12 @@ Future<void> main() async {
theme: ThemeUtil.getThemeModel(),
darkTheme: darkTheme,
themeMode: ThemeMode.light,

///EasyLoading
builder: EasyLoading.init(),
///语言
translations: Message(),
//默认语言
locale: LanguageUtil.getDefaultLocale(),
));

}
Loading

0 comments on commit 44d4c43

Please sign in to comment.