Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
e5ae754
Update main.dart
toly1994328 Apr 20, 2020
e9b09cd
删除无用代码
toly1994328 Apr 20, 2020
6e63ec3
冲突
toly1994328 Apr 20, 2020
98bb07c
使用无边线NoBorderExpansionTile
toly1994328 Apr 20, 2020
068d99c
优化收藏集显示
toly1994328 Apr 20, 2020
10369c1
图标
toly1994328 Apr 20, 2020
a853c7d
🎉完成收藏夹创建和删除
toly1994328 Apr 21, 2020
b139de5
:tada: Initial commit.
toly1994328 Apr 21, 2020
97308f2
:pencil: Initial commit.
toly1994328 Apr 21, 2020
b41b128
:pencil: 添加注释说明
toly1994328 Apr 21, 2020
810f9af
🏷️ MIT 协议
toly1994328 Apr 21, 2020
7f7a566
:sparkles: 收藏夹完成
toly1994328 Apr 23, 2020
84f2458
:sparkles: 收藏夹修改完成
toly1994328 Apr 23, 2020
23d02c5
:pencil: 修改文档
toly1994328 Apr 24, 2020
8c070f0
:art: 优化展示组件代码的存在形式
toly1994328 Apr 25, 2020
b178162
:art: 优化展示组件代码的存在形式
toly1994328 Apr 26, 2020
ef21901
:art: 优化展示组件代码的存在形式,stateless重构完毕
toly1994328 Apr 27, 2020
36a65f4
:art: 优化结构,调整包位置
toly1994328 Apr 27, 2020
da87301
:ambulance: ios白屏问题fix
toly1994328 Apr 28, 2020
b4d1f78
:pencil: 添加运行环境
toly1994328 Apr 28, 2020
548199c
:sparkles: item样式切换支持优化
toly1994328 Apr 28, 2020
fc84531
:ambulance: hero组件异常
toly1994328 Apr 29, 2020
60eb0f0
:art: stateful组件重构完毕
toly1994328 Apr 29, 2020
b58de9d
:art: 当前组件结构重构完毕
toly1994328 Apr 30, 2020
c0ff2b5
:zap: 优化详情
toly1994328 May 3, 2020
6446160
:pencil: 临时提交
toly1994328 May 3, 2020
9a7b642
:pencil: 临时提交
toly1994328 May 3, 2020
69cff81
:pencil: 修改文档
toly1994328 May 4, 2020
88c2a06
:pencil: 修改文档
toly1994328 May 6, 2020
43ad645
:pencil: 修改文档
toly1994328 May 6, 2020
7d065f1
:zap: 使用Flutter1.17
toly1994328 May 7, 2020
6bbbfd6
:pencil: 修改文档
toly1994328 May 7, 2020
fcf85cc
:pencil: 修改文档
toly1994328 May 9, 2020
2cc2e1d
:bug: 修复详情页右侧滑和linkto的冲突。优化代码结构
toly1994328 May 10, 2020
7db01d8
:pencil: 修改文档
toly1994328 May 10, 2020
d93a82c
:pencil: 修改文档
toly1994328 May 10, 2020
8a9f97c
:pencil: 修改文档
toly1994328 May 10, 2020
cc71231
Update README.md
toly1994328 May 14, 2020
7e02d23
:ambulance: 侧栏菜单跳转异常
toly1994328 May 27, 2020
88c7855
:sparkles: 添加CustomSingleChildLayout组件
toly1994328 Jun 3, 2020
b55f618
:sparkles: 添加CustomMultiChildLayout、LayoutId组件
toly1994328 Jun 6, 2020
6bb6bbc
:pencil: 文档更新
toly1994328 Jun 11, 2020
46addef
:art: 优化代码
toly1994328 Jun 15, 2020
3cc2418
:sparkles: 添加NestedScrollView、SliverOverlapAbsorber、SliverOverlapInje…
toly1994328 Jun 16, 2020
5fe4ca9
:pencil: 文档更新
toly1994328 Jun 16, 2020
ee14c6e
:sparkles: 添加应用版本检查页
toly1994328 Jun 16, 2020
375a903
:pencil: 更新文档
toly1994328 Jun 16, 2020
3ee66b1
:pencil: 更新文档
toly1994328 Jun 16, 2020
eed1773
:pencil: 要点集录初测
toly1994328 Jun 19, 2020
f9d679d
:sparkles: 开启性能浮层、CupertinoSegmentedControl组件
toly1994328 Jun 30, 2020
1bc7014
:sparkles: 开启性能浮层、CupertinoSegmentedControl组件
toly1994328 Jun 30, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
✨ 收藏夹完成
  • Loading branch information
toly1994328 committed Apr 23, 2020
commit 7f7a56632455684a809897f69b4e4ab6d63e162e
Binary file modified assets/flutter.db
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/app/res/cons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter_unit/app/style/TolyIcon.dart';
import 'package:flutter_unit/components/permanent/code/highlighter_style.dart';

class Cons {
static String version = 'V1.0.0';
static String version = 'V1.1.0';

static const MENU_INFO = <String>["关于", "帮助", "问题反馈"]; //菜单栏
static const ICONS_MAP = {
Expand Down
7 changes: 7 additions & 0 deletions lib/app/router.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_unit/views/pages/about/about_me_page.dart';
import 'package:flutter_unit/views/pages/about/about_app_page.dart';
import 'package:flutter_unit/views/pages/collect/category_show.dart';
import 'package:flutter_unit/views/pages/collect/collect_page.dart';
import 'package:flutter_unit/views/pages/search/serach_page.dart';
import 'package:flutter_unit/views/pages/setting/code_style_setting.dart';
Expand Down Expand Up @@ -33,6 +34,9 @@ class Router {
static const String code_style_setting = 'CodeStyleSettingPage';
static const String item_style_setting = 'ItemStyleSettingPage';


static const String category_show = 'CategoryShow';

static const String attr = 'AttrUnitPage';
static const String bug = 'BugUnitPage';
static const String paint = 'PaintUnitPage';
Expand Down Expand Up @@ -75,6 +79,9 @@ class Router {
case about_me:
return Right2LeftRouter(child: AboutMePage());

case category_show:
return Right2LeftRouter(child: CategoryShow(model: settings.arguments,));

default:
return MaterialPageRoute(
builder: (_) => Scaffold(
Expand Down
3 changes: 2 additions & 1 deletion lib/app/utils/Toast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import 'package:flutter/material.dart';

class Toast {
static toast(BuildContext context, String msg,
{duration = const Duration(milliseconds: 600)}) {
{duration = const Duration(milliseconds: 600),SnackBarAction action}) {
Scaffold.of(context).showSnackBar(SnackBar(
content: Text(msg),
duration: duration,
action: action,
backgroundColor: Theme.of(context).primaryColor,
));
}
Expand Down
5 changes: 5 additions & 0 deletions lib/blocs/category/category_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class CategoryBloc extends Bloc<CategoryEvent, CategoryState> {
await repository.deleteCategory(event.id);
add(EventLoadCategory());
}
if (event is EventToggleWidget) {
await repository.toggleCategory(event.categoryId,event.widgetId);
add(EventLoadCategory());
}

if (event is EventAddCategory) {
var categoryPo = CategoryPo(
Expand All @@ -62,6 +66,7 @@ class CategoryBloc extends Bloc<CategoryEvent, CategoryState> {
}
}


// if (event is EventAddCategory) {
// var collectPo = CategoryPo(
// name: event.name,
Expand Down
10 changes: 10 additions & 0 deletions lib/blocs/category/category_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ class EventLoadCategory extends CategoryEvent{
List<Object> get props => [];
}

class EventToggleWidget extends CategoryEvent{
final int widgetId;
final int categoryId;

EventToggleWidget({this.widgetId, this.categoryId});

@override
List<Object> get props => [widgetId,categoryId];
}

class EventDeleteCategory extends CategoryEvent{
final int id;

Expand Down
1 change: 1 addition & 0 deletions lib/blocs/category/category_state.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:equatable/equatable.dart';
import 'package:flutter_unit/model/category_model.dart';
import 'package:flutter_unit/model/widget_model.dart';

/// create by 张风捷特烈 on 2020-04-21
/// contact me by email [email protected]
Expand Down
44 changes: 44 additions & 0 deletions lib/blocs/category_widget/category_widget_bloc.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_unit/blocs/category/category_bloc.dart';
import 'package:flutter_unit/blocs/category/category_event.dart';
import 'package:flutter_unit/repositories/itf/category_repository.dart';

import 'category_widget_event.dart';
import 'category_widget_state.dart';

/// create by 张风捷特烈 on 2020-04-21
/// contact me by email [email protected]
/// 说明:

class CategoryWidgetBloc
extends Bloc<CategoryWidgetEvent, CategoryWidgetState> {
final CategoryBloc categoryBloc;

CategoryWidgetBloc({@required this.categoryBloc}) {
print('CategoryBloc');
}

CategoryRepository get repository => categoryBloc.repository;

@override
CategoryWidgetState get initialState => CategoryWidgetEmptyState(); //初始状态

@override
Stream<CategoryWidgetState> mapEventToState(
CategoryWidgetEvent event) async* {
if (event is EventLoadCategoryWidget) {
final widgets =
await repository.loadCategoryWidgets(categoryId: event.categoryId);
yield widgets.isNotEmpty
? CategoryWidgetLoadedState(widgets)
: CategoryWidgetEmptyState();
categoryBloc.add(EventLoadCategory());
}

if (event is EventToggleCategoryWidget) {
await repository.toggleCategory(event.categoryId, event.widgetId);
add(EventLoadCategoryWidget(event.categoryId));
}
}
}
55 changes: 55 additions & 0 deletions lib/blocs/category_widget/category_widget_event.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';

/// create by 张风捷特烈 on 2020-04-21
/// contact me by email [email protected]
/// 说明:

abstract class CategoryWidgetEvent extends Equatable{
@override
List<Object> get props => [];
}

//class EventLoadCategory extends CategoryWidgetEvent{
// @override
// List<Object> get props => [];
//}

class EventLoadCategoryWidget extends CategoryWidgetEvent{
final int categoryId;

EventLoadCategoryWidget(this.categoryId);

@override
List<Object> get props => [categoryId];
}

class EventToggleCategoryWidget extends CategoryWidgetEvent{
final int categoryId;
final int widgetId;

EventToggleCategoryWidget(this.categoryId,this.widgetId);

@override
List<Object> get props => [categoryId,widgetId];
}

//class EventDeleteCategory extends CategoryWidgetEvent{
// final int id;
//
// EventDeleteCategory({@required this.id});
//
// @override
// List<Object> get props => [id];
//}
//
//class EventAddCategory extends CategoryWidgetEvent{
// final String name;
// final String info;
// final String color;
//
// EventAddCategory({@required this.name, this.info, this.color});
//
// @override
// List<Object> get props => [name,info,color];
//}
32 changes: 32 additions & 0 deletions lib/blocs/category_widget/category_widget_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:equatable/equatable.dart';
import 'package:flutter_unit/model/category_model.dart';
import 'package:flutter_unit/model/widget_model.dart';

/// create by 张风捷特烈 on 2020-04-21
/// contact me by email [email protected]
/// 说明:

class CategoryWidgetState extends Equatable{
@override
List<Object> get props => [];

}


class CategoryWidgetLoadedState extends CategoryWidgetState {
final List<WidgetModel> widgets;

CategoryWidgetLoadedState(this.widgets);

List<Object> get props => [widgets];

}

class CategoryWidgetEmptyState extends CategoryWidgetState{
List<Object> get props => [];
}


class AddCategoryFailed extends CategoryWidgetState{

}
2 changes: 1 addition & 1 deletion lib/components/permanent/circle_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CircleText extends StatelessWidget {
color: backgroundColor??Color(0xffD8F5FF),
),
child: Text(
text.substring(0, 2),
text.length>2?text.substring(0, 2):text,
style: TextStyle(
fontSize: fontSize,
color: color,
Expand Down
36 changes: 19 additions & 17 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@


import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_unit/blocs/category_widget/category_widget_bloc.dart';
import 'package:flutter_unit/storage/app_storage.dart';
import 'package:flutter_unit/views/pages/splash/unit_splash.dart';

Expand Down Expand Up @@ -56,10 +55,9 @@ class BlocWrapper extends StatelessWidget {

BlocProvider<DetailBloc>(
create: (_) => DetailBloc(repository: repository)),

BlocProvider<CategoryBloc>(create: (_) {
return CategoryBloc(repository: categoryRepo)..add(EventLoadCategory());
} ),
BlocProvider<CategoryBloc>(
create: (_) =>
CategoryBloc(repository: categoryRepo)..add(EventLoadCategory())),

BlocProvider<CollectBloc>(
create: (_) =>
Expand All @@ -75,19 +73,23 @@ class FlutterApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocBuilder<GlobalBloc, GlobalState>(builder: (_, state) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
onGenerateRoute: Router.generateRoute,
theme: ThemeData(
primarySwatch: state.themeColor,
fontFamily: state.fontFamily,
),
home:
return BlocProvider<CategoryWidgetBloc>(
create: (_) => CategoryWidgetBloc(
categoryBloc: BlocProvider.of<CategoryBloc>(context)),
child: MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
onGenerateRoute: Router.generateRoute,
theme: ThemeData(
primarySwatch: state.themeColor,
fontFamily: state.fontFamily,
),
home:
// NavPage()
UnitSplash()
UnitSplash()
// UnitNavigation(),
);
),
);
});
}
}
Expand Down
9 changes: 8 additions & 1 deletion lib/model/category_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CategoryModel extends Equatable{
info: po.info,
createDate: DateFormat('yyyy-MM-dd HH:mm').format(po.created),
imageCover: po.image,
count: 10,
count: po.count,
color: ColorUtils.parse(po.color),
);
}
Expand All @@ -50,4 +50,11 @@ class CategoryModel extends Equatable{
count,
color,
];

@override
String toString() {
return 'CategoryModel{id: $id, name: $name, info: $info, createDate: $createDate, imageCover: $imageCover, count: $count, color: $color}';
}


}
27 changes: 14 additions & 13 deletions lib/repositories/impl/catagory_db_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:flutter_unit/storage/po/widget_po.dart';

/// create by 张风捷特烈 on 2020-04-21
/// contact me by email [email protected]
/// 说明:
/// 说明:

class CategoryDbRepository implements CategoryRepository {
final AppStorage storage;
Expand All @@ -20,43 +20,44 @@ class CategoryDbRepository implements CategoryRepository {
}

@override
Future<bool> addCategory(CategoryPo categoryPo) async{
Future<bool> addCategory(CategoryPo categoryPo) async {
var success = await _collectDao.insert(categoryPo);
return success != -1;
}

@override
Future<bool> check(int categoryId, int widgetId) async{
Future<bool> check(int categoryId, int widgetId) async {
return await _collectDao.existWidgetInCollect(categoryId, widgetId);

}

@override
Future<void> deleteCategory(int id) async{
Future<void> deleteCategory(int id) async {
await _collectDao.deleteCollect(id);
}

@override
Future<List<CategoryModel>> loadCategories() async{
Future<List<CategoryModel>> loadCategories() async {
var data = await _collectDao.queryAll();
var collects = data.map((e) => CategoryPo.fromJson(e)).toList();
return collects.map(CategoryModel.fromPo).toList();
}

@override
Future<List<WidgetModel>> loadCategoryWidgets({int categoryId = 0}) async{
var rawData = await _collectDao.loadCollectWidgets(1);
Future<List<WidgetModel>> loadCategoryWidgets({int categoryId = 0}) async {
var rawData = await _collectDao.loadCollectWidgets(categoryId);
var widgets = rawData.map((e) => WidgetPo.fromJson(e)).toList();
return widgets.map(WidgetModel.fromPo).toList();
}

@override
Future<void> toggleCategory(int id) async{
return await _collectDao.toggleCollectDefault(id);

Future<void> toggleCategory(int categoryId, int widgetId) async {
return await _collectDao.toggleCollect( categoryId, widgetId);
}


@override
Future<List<int>> getCategoryByWidget(int widgetId) async {
return await _collectDao.categoryWidgetIds(widgetId);
}

//
// @override
Expand All @@ -70,4 +71,4 @@ class CategoryDbRepository implements CategoryRepository {
// Future<bool> checkCollected(int collectId, int widgetId) async {
//
// }
}
}
Loading