Skip to content

Commit

Permalink
Merge commit '449e8a33e2997c1f00f9eb514892e15f3c3643ad'
Browse files Browse the repository at this point in the history
# Conflicts:
#	pubspec.yaml
  • Loading branch information
Elemen committed Feb 15, 2022
2 parents 570a46d + 449e8a3 commit 422f5ae
Show file tree
Hide file tree
Showing 27 changed files with 1,780 additions and 134 deletions.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
Shorey
<br>
</h1>
这是一款开源笔记应用, 支持Android/iOS双平台, 使用Flutter 2开发, 体验Flutter的同时也希望做一个能成为个人知识中转站的应用, 任重道远 :)
这是一款开源笔记应用, 支持Android/iOS双平台, 使用Flutter 2开发, 体验Flutter的同时也希望做一个能成为个人知识中转站的应用, 让你更方便的把平时收集到的信息记录下来, 最后沉淀到知识库中.

后边会先开发联动Notion, 让你的Notion成为后台知识库.

Shorey is a simple note app which is built with Flutter 2 and supports both Android/iOS platforms. It provides me full experience of interacting with Flutter and in the meantime I hope it can be your knowledge/memory transition tool, and yes, there still much work to do.

Now I focus on linking Notion, in order to make Notion your backend knowledge database.

**特点:**
* Google Material UI风格
* 轻量化, 只有10m大小
Expand All @@ -20,17 +24,22 @@ Shorey is a simple note app which is built with Flutter 2 and supports both Andr
* 国际化适配, 支持中英文切换
* 更多功能开发中…

> 软件还在开发阶段,可能会有颠覆性的改变,请注意。It is still under developing, breaking changes may occur.

## 分享
[个人笔记软件Shorey开源(一) - 软件介绍/产品理念](https://mp.weixin.qq.com/s/W-3AhgCHSIQWLomPuyIPwA)

[个人笔记软件Shorey开源(二) - 使用Flutter开发App入门](https://mp.weixin.qq.com/s/_7Kl9nJLHaX6ZbZzLKREYQ)

## 马上开始
**应用运行要求:**
1. Android 5.0 +
1. Android 5.0+
2. iOS 10+

**项目编译要求:**
1. Android SDK 28/Xcode 13
2. Flutter SDK 2.5.3
2. Flutter SDK 2.8.1

## 应用展示
UI部分大量参考了Flutter官方的Gallery应用. 另外还在关于页埋了个小彩蛋, 希望喜欢.
Expand All @@ -44,7 +53,7 @@ Android: 可直接在Release板块下载apk体验.或使用下方二维码下载
![lqHI](https://user-images.githubusercontent.com/10020581/140268740-ff2558a8-c8d3-4ae6-ac08-8b9bec2a1c10.png)


iOS: 可下载源码使用 flutter run --release 编译体验, 后期考虑上testflight.
iOS: 可下载源码使用 $ flutter run --release 编译体验, 后期考虑上testflight.


## 技术架构
Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
Expand Down
10 changes: 10 additions & 0 deletions lib/config/api.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
///
/// Author: Elemen
/// Github: https://github.com/elementlo
/// Date: 2022/1/13
/// Description:
///
const String notionUsers = 'v1/users';
const String retrieveNotionDatabase = 'v1/databases';
const String retrieveNotionPages = 'v1/pages';
12 changes: 11 additions & 1 deletion lib/config/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,22 @@ class Routes {

///mantra
class Mantra {

static String mantra1 = S.current.mantra1;
static String mantra2 = S.current.mantra2;
static String mantra3 = S.current.mantra3;
static String mantra4 = 'El psy kongroo.';

static List<String> mantraList = [mantra1, mantra2, mantra3, mantra4];
static List<String> get mantraList => updateMantra();

static List<String> updateMantra(){
mantra1 = S.current.mantra1;
mantra2 = S.current.mantra2;
mantra3 = S.current.mantra3;
mantra4 = 'El psy kongroo.';
return [mantra1, mantra2, mantra3, mantra4];
}

}

class SColor {
Expand Down
10 changes: 5 additions & 5 deletions lib/database/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ LazyDatabase _openConnection() {
}

@DriftDatabase(tables: [ToDos, Categories, HeatGraph, ActionsHistory])
class DbProvider extends _$DbProvider {
DbProvider() : super(_openConnection());
class DatabaseProvider extends _$DbProvider {
DatabaseProvider() : super(_openConnection());

@override
int get schemaVersion => 1;
Expand Down Expand Up @@ -158,15 +158,15 @@ class DbProvider extends _$DbProvider {
return count;
}

Future deleteCategory(int id) async {
Future deleteCategory(int id) {
return (delete(categories)..where((tbl) => tbl.id.equals(id))).go();
}

Future insertCategory(CategoriesCompanion entity) async {
Future insertCategory(CategoriesCompanion entity) {
return into(categories).insert(entity);
}

Future updateCategory(CategoriesCompanion entity) async {
Future updateCategory(CategoriesCompanion entity) {
return update(categories).replace(entity);
}

Expand Down
8 changes: 8 additions & 0 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class MessageLookup extends MessageLookupByLibrary {
"archivedLess": MessageLookupByLibrary.simpleMessage("Archived less"),
"archivedList": MessageLookupByLibrary.simpleMessage("Archived"),
"archivedMore": MessageLookupByLibrary.simpleMessage("More"),
"bindNotion": MessageLookupByLibrary.simpleMessage("Link Notion"),
"cancelAlertTime":
MessageLookupByLibrary.simpleMessage("Cleared alert time"),
"categoryInformation":
Expand All @@ -56,6 +57,10 @@ class MessageLookup extends MessageLookupByLibrary {
"itemAlert": MessageLookupByLibrary.simpleMessage("Title"),
"itemRemark": MessageLookupByLibrary.simpleMessage("Remark"),
"languages": MessageLookupByLibrary.simpleMessage("Languages"),
"linkNotionDatabase":
MessageLookupByLibrary.simpleMessage("Link root page"),
"linkNotionInfo": MessageLookupByLibrary.simpleMessage(
"Fill in the blanks to link Notion"),
"mainCategory": MessageLookupByLibrary.simpleMessage("Category"),
"mainFocusToday":
MessageLookupByLibrary.simpleMessage("Main Focus Today"),
Expand All @@ -68,6 +73,9 @@ class MessageLookup extends MessageLookupByLibrary {
"I am free and that is why I am lost."),
"noAlert": MessageLookupByLibrary.simpleMessage("No alert"),
"notificationTitle": MessageLookupByLibrary.simpleMessage("Retrospect"),
"notion": MessageLookupByLibrary.simpleMessage("Notion account"),
"notionPageId": MessageLookupByLibrary.simpleMessage("Page ID"),
"notionToken": MessageLookupByLibrary.simpleMessage("Notion token"),
"retrospect": MessageLookupByLibrary.simpleMessage("Retrospect"),
"settings": MessageLookupByLibrary.simpleMessage("Settings"),
"shoreyMomment": MessageLookupByLibrary.simpleMessage("Shorey moment"),
Expand Down
7 changes: 7 additions & 0 deletions lib/generated/intl/messages_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class MessageLookup extends MessageLookupByLibrary {
"archivedLess": MessageLookupByLibrary.simpleMessage("归档较少"),
"archivedList": MessageLookupByLibrary.simpleMessage("已归档"),
"archivedMore": MessageLookupByLibrary.simpleMessage("较多"),
"bindNotion": MessageLookupByLibrary.simpleMessage("关联Notion"),
"cancelAlertTime": MessageLookupByLibrary.simpleMessage("已取消提醒时间"),
"categoryInformation": MessageLookupByLibrary.simpleMessage("类别信息"),
"categoryList": MessageLookupByLibrary.simpleMessage("类别"),
Expand All @@ -52,6 +53,9 @@ class MessageLookup extends MessageLookupByLibrary {
"itemAlert": MessageLookupByLibrary.simpleMessage("标题"),
"itemRemark": MessageLookupByLibrary.simpleMessage("备注"),
"languages": MessageLookupByLibrary.simpleMessage("语言"),
"linkNotionDatabase": MessageLookupByLibrary.simpleMessage("关联根页面"),
"linkNotionInfo":
MessageLookupByLibrary.simpleMessage("填写下面两项信息使Shorey与Notion连接"),
"mainCategory": MessageLookupByLibrary.simpleMessage("类别"),
"mainFocusToday": MessageLookupByLibrary.simpleMessage("今日聚焦"),
"mantra": MessageLookupByLibrary.simpleMessage("格言"),
Expand All @@ -61,6 +65,9 @@ class MessageLookup extends MessageLookupByLibrary {
"mantra3": MessageLookupByLibrary.simpleMessage("我是自由的, 那就是我迷失的原因."),
"noAlert": MessageLookupByLibrary.simpleMessage("不提醒"),
"notificationTitle": MessageLookupByLibrary.simpleMessage("回顾"),
"notion": MessageLookupByLibrary.simpleMessage("Notion账户"),
"notionPageId": MessageLookupByLibrary.simpleMessage("Page ID"),
"notionToken": MessageLookupByLibrary.simpleMessage("Notion token"),
"retrospect": MessageLookupByLibrary.simpleMessage("回顾"),
"settings": MessageLookupByLibrary.simpleMessage("设置"),
"shoreyMomment": MessageLookupByLibrary.simpleMessage("Shorey时刻"),
Expand Down
60 changes: 60 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,11 @@
"deleteCategory": "Delete",
"categoryInformation": "Category Information",
"addCategoryName": "Name",
"editCategory": "Edit"
"editCategory": "Edit",
"bindNotion": "Link Notion",
"notion": "Notion account",
"linkNotionDatabase": "Link root page",
"notionToken": "Notion token",
"linkNotionInfo": "Fill in the blanks to link Notion",
"notionPageId": "Page ID"
}
8 changes: 7 additions & 1 deletion lib/l10n/intl_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,11 @@
"deleteCategory": "删除",
"categoryInformation": "类别信息",
"addCategoryName": "名字",
"editCategory": "编辑"
"editCategory": "编辑",
"bindNotion": "关联Notion",
"notion": "Notion账户",
"linkNotionDatabase": "关联根页面",
"notionToken": "Notion token",
"linkNotionInfo": "填写下面两项信息使Shorey与Notion连接",
"notionPageId": "Page ID"
}
38 changes: 30 additions & 8 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'dart:convert';

import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
Expand All @@ -13,6 +16,7 @@ import 'package:spark_list/pages/mantra_edit_page.dart';
import 'package:spark_list/pages/root_page.dart';
import 'package:spark_list/pages/settings_page.dart';
import 'package:spark_list/resource/data_provider.dart';
import 'package:spark_list/resource/http_provider.dart';
import 'package:spark_list/routes.dart';
import 'package:spark_list/view_model/config_view_model.dart';
import 'package:spark_list/view_model/home_view_model.dart';
Expand All @@ -22,22 +26,23 @@ import 'package:timezone/timezone.dart' as tz;
import 'config/theme_data.dart';
import 'generated/l10n.dart';

late DataProvider _dataProvider;
late DbProvider _dbProvider;
late DataStoreProvider dsProvider;
late DatabaseProvider dbProvider;
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();

void main() async {
WidgetsFlutterBinding.ensureInitialized();
_configureLocalTimeZone();
await _initNotificationsSettings();
_dataProvider = DataProvider();
await _dataProvider.ready;
await _dataProvider.getLocale();
_dbProvider = DbProvider();
dsProvider = DataStoreProvider();
await dsProvider.ready;
await dsProvider.getLocale();
dbProvider = DatabaseProvider();
_configHttpClient();
runApp(ProviderWidget2<ConfigViewModel, HomeViewModel>(
ConfigViewModel(_dataProvider, _dbProvider),
HomeViewModel(_dataProvider, _dbProvider),
ConfigViewModel(),
HomeViewModel(),
onModelReady: (cViewModel, hViewModel) async {
await cViewModel?.initCategoryDemosList();
await cViewModel?.getCategoryList();
Expand All @@ -46,6 +51,23 @@ void main() async {
_configLoading();
}

_parseAndDecode(String response) {
return jsonDecode(response);
}

parseJson(String text) {
return compute(_parseAndDecode, text);
}

void _configHttpClient(){
dio.interceptors.add(LogInterceptor(responseBody: true, responseHeader: false));
dio.options.baseUrl = 'https://api.notion.com/';
dio.options.headers.addAll({'Notion-Version':'2021-05-13'});
dio.options.connectTimeout = 5000;
dio.options.receiveTimeout = 7000;
(dio.transformer as DefaultTransformer).jsonDecodeCallback = parseJson;
}

void _configLoading() {
EasyLoading.instance..indicatorType = EasyLoadingIndicatorType.threeBounce;
}
Expand Down
1 change: 1 addition & 0 deletions lib/model/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,4 @@ class CategoryDemo{

CategoryDemo({this.id, this.name});
}

Loading

0 comments on commit 422f5ae

Please sign in to comment.