Skip to content

Commit

Permalink
Merge pull request #133 from abc873693/feature/separate
Browse files Browse the repository at this point in the history
Feature/separate
  • Loading branch information
abc873693 authored Oct 13, 2024
2 parents 5dfc865 + 290db09 commit a47f03f
Show file tree
Hide file tree
Showing 221 changed files with 4,431 additions and 4,775 deletions.
68 changes: 40 additions & 28 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
.DS_Store
.atom/
.idea/
.vscode/*
.melos_tool/*
!.vscode/tasks.json
!.vscode/settings.json

.vscode/
**/lcov.info
coverage
.packages
.pub/
.dart_tool/
Expand All @@ -16,26 +14,40 @@ flutter_export_environment.sh
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader

# Misc
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
firebase-debug.log*

# Firebase cache
.firebase/

# FVM Version Cache
.fvm/
Podfile
Podfile.lock
Pods/
.symlinks/
**/Flutter/App.framework/
**/Flutter/ephemeral/
**/Flutter/Flutter.framework/
**/Flutter/Generated.xcconfig
**/Flutter/flutter_assets/

ServiceDefinitions.json
xcuserdata/
**/DerivedData/

local.properties
keystore.properties
.gradle/
gradlew
gradlew.bat
gradle-wrapper.jar
.flutter-plugins-dependencies
*.iml

generated_plugin_registrant.dart
GeneratedPluginRegistrant.h
GeneratedPluginRegistrant.m
GeneratedPluginRegistrant.java
GeneratedPluginRegistrant.swift
build/
.flutter-plugins

.project
.classpath
.settings
**/.fvm

.melos_tool/
397 changes: 397 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

48 changes: 42 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,48 @@

## 套件

| Name | pub.dev | 說明 |
|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|---------------------|
| `ap_common` | [![ap_common pub.dev badge](https://img.shields.io/pub/v/ap_common.svg?style=flat-square)](https://pub.dev/packages/ap_common/) | 函式庫與相關介面共用 |
| `ap_common_plugin` | [![ap_common pub.dev badge](https://img.shields.io/pub/v/ap_common_plugin.svg?style=flat-square)](https://pub.dev/packages/ap_common_plugin/) | 課表小工具 |
| `ap_common_firebase` | [![ap_common pub.dev badge](https://img.shields.io/pub/v/ap_common_firebase.svg?style=flat-square)](https://pub.dev/packages/ap_common_firebase/) | 服務 `Firebase` 的整合實作 |
| Name | pub.dev | 說明 |
|-------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------|
| `ap_common` | [![ap_common pub.dev badge](https://img.shields.io/pub/v/ap_common.svg?style=flat-square)](https://pub.dev/packages/ap_common/) | 函式庫與相關介面共用 |
| `ap_common_core` | [![ap_common pub.dev badge](https://img.shields.io/pub/v/ap_common.svg?style=flat-square)](https://pub.dev/packages/ap_common_core/) | 純 Dart 的基本類別 |
| `ap_common_flutter_core` | [![ap_common pub.dev badge](https://img.shields.io/pub/v/ap_common_flutter_core.svg?style=flat-square)](https://pub.dev/packages/ap_common_flutter_core/) | 基於 Flutter 框架的核心基本類別 |
| `ap_common_flutter_platform` | [![ap_common pub.dev badge](https://img.shields.io/pub/v/ap_common_flutter_platform.svg?style=flat-square)](https://pub.dev/packages/ap_common_flutter_platform/) | 原生功能實作 |
| `ap_common_flutter_ui` | [![ap_common pub.dev badge](https://img.shields.io/pub/v/ap_common_flutter_ui.svg?style=flat-square)](https://pub.dev/packages/ap_common_flutter_ui/) | UI 實作但不包含原生功能整合 |
| `ap_common_flutter_announcement_ui` | [![ap_common pub.dev badge](https://img.shields.io/pub/v/ap_common_announcement_ui.svg?style=flat-square)](https://pub.dev/packages/ap_common_announcement_ui/) | 最新消息服務相關的介面實作 |
| `ap_common_plugin` | [![ap_common pub.dev badge](https://img.shields.io/pub/v/ap_common_plugin.svg?style=flat-square)](https://pub.dev/packages/ap_common_plugin/) | 課表小工具 |
| `ap_common_firebase` | [![ap_common pub.dev badge](https://img.shields.io/pub/v/ap_common_firebase.svg?style=flat-square)](https://pub.dev/packages/ap_common_firebase/) | 服務 `Firebase` 的整合實作 |

## 套件架構

### v0.26 以後

```mermaid
flowchart TD
ap_common[ap_common] --- ap_common_flutter_ui[ap_common_flutter_ui] --- ap_common_flutter_core
ap_common --- ap_common_flutter_platform[ap_common_flutter_platform] --- ap_common_flutter_core
ap_common --- ap_common_announcement_ui[ap_common_announcement_ui] --- ap_common_flutter_core
ap_common_firebase --- ap_common_flutter_core
ap_common_plugin --- ap_common_flutter_core
ap_common_flutter_core -- Dart Level --> ap_common_core
```

### v0.25 前

```mermaid
flowchart TD
ap_common_firebase --- ap_common
ap_common_plugin --- ap_common
```

## 套件使用要求

- Flutter `v1.20` 以上
- Flutter `v3.22` 以上
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ include: package:lint/strict.yaml
analyzer:
exclude:
# l10n generated code
- lib/l10n/intl/*.dart
- lib/l10n/l10n.dart
- example/lib/l10n/intl/*.dart
- example/lib/l10n/l10n.dart
- packages/ap_common_flutter_core/lib/src/l10n/intl/*.dart
- packages/ap_common_flutter_core/lib/src/l10n/l10n.dart
- apps/example/lib/l10n/intl/*.dart
- apps/example/lib/l10n/l10n.dart
# example
# - example/**
# other generated files
- lib/models/*.g.dart
- lib/**/*.g.dart
- '**/*.g.dart'

linter:
rules:
Expand Down
10 changes: 5 additions & 5 deletions apps/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ PODS:
- FlutterMacOS
- sign_in_with_apple (0.0.1):
- Flutter
- sqflite (0.0.3):
- sqflite_darwin (0.0.4):
- Flutter
- FlutterMacOS
- url_launcher_ios (0.0.1):
Expand All @@ -81,7 +81,7 @@ DEPENDENCIES:
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sign_in_with_apple (from `.symlinks/plugins/sign_in_with_apple/ios`)
- sqflite (from `.symlinks/plugins/sqflite/darwin`)
- sqflite_darwin (from `.symlinks/plugins/sqflite_darwin/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)

SPEC REPOS:
Expand Down Expand Up @@ -126,8 +126,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sign_in_with_apple:
:path: ".symlinks/plugins/sign_in_with_apple/ios"
sqflite:
:path: ".symlinks/plugins/sqflite/darwin"
sqflite_darwin:
:path: ".symlinks/plugins/sqflite_darwin/darwin"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"

Expand All @@ -153,7 +153,7 @@ SPEC CHECKSUMS:
share_plus: 8875f4f2500512ea181eef553c3e27dba5135aad
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
sign_in_with_apple: f3bf75217ea4c2c8b91823f225d70230119b8440
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
sqflite_darwin: a553b1fd6fe66f53bbb0fe5b4f5bab93f08d7a13
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe

PODFILE CHECKSUM: c9ef12c3fd571f251c0b25e8bb818e50ec70ffe1
Expand Down
12 changes: 4 additions & 8 deletions apps/example/lib/app.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import 'package:ap_common/pages/about_us_page.dart';
import 'package:ap_common/pages/announcement/home_page.dart';
import 'package:ap_common/resources/ap_theme.dart';
import 'package:ap_common/utils/ap_localizations.dart';
import 'package:ap_common/utils/preferences.dart';
import 'package:ap_common/ap_common.dart';
import 'package:ap_common_example/config/constants.dart';
import 'package:ap_common_example/pages/home_page.dart';
import 'package:ap_common_example/utils/app_localizations.dart';
Expand Down Expand Up @@ -36,8 +32,8 @@ class MyAppState extends State<MyApp> with WidgetsBindingObserver {

@override
void initState() {
themeMode = ThemeMode
.values[Preferences.getInt(Constants.PREF_THEME_MODE_INDEX, 0)];
themeMode = ThemeMode.values[
PreferenceUtil.instance.getInt(Constants.PREF_THEME_MODE_INDEX, 0)];
WidgetsBinding.instance.addObserver(this);
Future<void>.microtask(() async {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
Expand Down Expand Up @@ -72,7 +68,7 @@ class MyAppState extends State<MyApp> with WidgetsBindingObserver {
child: MaterialApp(
localeResolutionCallback:
(Locale? locale, Iterable<Locale> supportedLocales) {
final String languageCode = Preferences.getString(
final String languageCode = PreferenceUtil.instance.getString(
Constants.PREF_LANGUAGE_CODE,
ApSupportLanguageConstants.system,
);
Expand Down
17 changes: 10 additions & 7 deletions apps/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:io';

import 'package:ap_common/resources/ap_icon.dart';
import 'package:ap_common/utils/preferences.dart';
import 'package:ap_common/ap_common.dart';
import 'package:ap_common_example/app.dart';
import 'package:ap_common_example/config/constants.dart';
import 'package:flutter/cupertino.dart';
Expand All @@ -12,13 +11,17 @@ import 'package:google_sign_in_dartio/google_sign_in_dartio.dart';
// ignore_for_file: lines_longer_than_80_chars
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Preferences.init(key: Constants.key, iv: Constants.iv);
registerOneForAll();
registerApCommonService();
await (PreferenceUtil.instance as ApPreferenceUtil)
.init(key: Constants.key, iv: Constants.iv);
if (!kIsWeb && (Platform.isMacOS || Platform.isWindows || Platform.isLinux)) {
GoogleSignInDart.register(
clientId:
'141403473068-9gii2blqbggijifq0ijoqkqv8oj2i2ff.apps.googleusercontent.com',);
clientId:
'141403473068-9gii2blqbggijifq0ijoqkqv8oj2i2ff.apps.googleusercontent.com',
);
}
ApIcon.code =
Preferences.getString(Constants.PREF_ICON_STYLE_CODE, ApIcon.outlined);
ApIcon.code = PreferenceUtil.instance
.getString(Constants.PREF_ICON_STYLE_CODE, ApIcon.outlined);
runApp(const MyApp());
}
7 changes: 1 addition & 6 deletions apps/example/lib/pages/diolog_utils_page.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import 'package:ap_common/models/version_info.dart';
import 'package:ap_common/utils/ap_utils.dart';
import 'package:ap_common/utils/app_tracking_utils.dart';
import 'package:ap_common/utils/dialog_utils.dart';
import 'package:ap_common/utils/notification_utils.dart';
import 'package:ap_common/ap_common.dart';
import 'package:ap_common_example/config/constants.dart';
import 'package:ap_common_example/utils/app_localizations.dart';
import 'package:flutter/material.dart';
Expand All @@ -15,7 +11,6 @@ class DialogUtilsTestPage extends StatefulWidget {
class _DialogUtilsTestPageState extends State<DialogUtilsTestPage> {
late AppLocalizations app;

Day day = NotificationUtils.getDay(DateTime.now().weekday);
TimeOfDay time = TimeOfDay.now();

@override
Expand Down
37 changes: 13 additions & 24 deletions apps/example/lib/pages/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
import 'package:ap_common/api/announcement_helper.dart';
import 'package:ap_common/models/user_info.dart';
import 'package:ap_common/pages/about_us_page.dart';
import 'package:ap_common/pages/announcement/home_page.dart';
import 'package:ap_common/pages/announcement_content_page.dart';
import 'package:ap_common/resources/ap_icon.dart';
import 'package:ap_common/resources/ap_theme.dart';
import 'package:ap_common/scaffold/home_page_scaffold.dart';
import 'package:ap_common/utils/ap_localizations.dart';
import 'package:ap_common/utils/ap_utils.dart';
import 'package:ap_common/utils/notification_utils.dart';
import 'package:ap_common/utils/preferences.dart';
import 'package:ap_common/widgets/ap_drawer.dart';
import 'package:ap_common/ap_common.dart';
import 'package:ap_common_example/config/constants.dart';
import 'package:ap_common_example/pages/diolog_utils_page.dart';
import 'package:ap_common_example/pages/login_page.dart';
Expand Down Expand Up @@ -88,7 +76,7 @@ class HomePageState extends State<HomePage> {
@override
void initState() {
_getAnnouncements();
if (Preferences.getBool(Constants.PREF_AUTO_LOGIN, false)) {
if (PreferenceUtil.instance.getBool(Constants.PREF_AUTO_LOGIN, false)) {
_login();
} else {
checkLogin();
Expand Down Expand Up @@ -126,8 +114,8 @@ class HomePageState extends State<HomePage> {
content: content,
drawer: ApDrawer(
userInfo: userInfo,
displayPicture:
Preferences.getBool(Constants.PREF_DISPLAY_PICTURE, true),
displayPicture: PreferenceUtil.instance
.getBool(Constants.PREF_DISPLAY_PICTURE, true),
imageAsset: drawerIcon,
onTapHeader: () {
if (isLogin) {
Expand Down Expand Up @@ -194,7 +182,7 @@ class HomePageState extends State<HomePage> {
SchoolInfoPage(),
),
),
if (NotificationUtils.isSupport)
if (NotificationUtil.instance.isSupport)
DrawerItem(
icon: ApIcon.dateRange,
title: app.localNotificationTest,
Expand Down Expand Up @@ -228,7 +216,8 @@ class HomePageState extends State<HomePage> {
icon: ApIcon.powerSettingsNew,
title: ap.logout,
onTap: () async {
await Preferences.setBool(Constants.PREF_AUTO_LOGIN, false);
await PreferenceUtil.instance
.setBool(Constants.PREF_AUTO_LOGIN, false);
isLogin = false;
userInfo = null;
content = null;
Expand Down Expand Up @@ -283,7 +272,7 @@ class HomePageState extends State<HomePage> {
break;
}
} else {
ApUtils.showToast(context, ap.notLogin);
UiUtil.instance.showToast(context, ap.notLogin);
}
}

Expand Down Expand Up @@ -337,7 +326,7 @@ class HomePageState extends State<HomePage> {
setState(() {
this.userInfo = userInfo;
});
if (Preferences.getBool(Constants.PREF_DISPLAY_PICTURE, true)) {
if (PreferenceUtil.instance.getBool(Constants.PREF_DISPLAY_PICTURE, true)) {
_getUserPicture();
}
}
Expand All @@ -362,12 +351,12 @@ class HomePageState extends State<HomePage> {

Future<void> _login() async {
await Future<void>.delayed(const Duration(microseconds: 30));
// var username = Preferences.getString(Constants.PREF_USERNAME, '');
// var username = PreferenceUtil.instance.getString(Constants.PREF_USERNAME, '');
// ignore: lines_longer_than_80_chars
// var password = Preferences.getStringSecurity(Constants.PREF_PASSWORD, '');
// var password = PreferenceUtil.instance.getStringSecurity(Constants.PREF_PASSWORD, '');
//to login
isLogin = true;
Preferences.setBool(Constants.PREF_IS_OFFLINE_LOGIN, false);
PreferenceUtil.instance.setBool(Constants.PREF_IS_OFFLINE_LOGIN, false);
_getUserInfo();
if (state != HomeState.finish) {
_getAnnouncements();
Expand Down Expand Up @@ -418,7 +407,7 @@ class HomePageState extends State<HomePage> {
void _openPage(Widget page, {bool needLogin = false}) {
if (!isTablet) Navigator.of(context).pop();
if (needLogin && !isLogin) {
ApUtils.showToast(
UiUtil.instance.showToast(
context,
ApLocalizations.of(context).notLoginHint,
);
Expand Down
Loading

0 comments on commit a47f03f

Please sign in to comment.