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 24, 2020
commit 23d02c5a4fbe07a2a8067a87d0652ccf35110591
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### FlutterUnit apk 下载体验:


![](https://user-gold-cdn.xitu.io/2020/4/21/17199d41c75cfc9d?w=300&h=390&f=png&s=23245)
![](https://user-gold-cdn.xitu.io/2020/4/24/171a9911d22d34a8?w=300&h=390&f=png&s=22765)

---

Expand Down
4 changes: 1 addition & 3 deletions lib/blocs/category/category_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import 'category_state.dart';
class CategoryBloc extends Bloc<CategoryEvent, CategoryState> {
final CategoryRepository repository;

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

@override
CategoryState get initialState => CategoryEmptyState(); //初始状态
Expand Down
1 change: 0 additions & 1 deletion lib/blocs/category/category_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class EventLoadCategory extends CategoryEvent{
class EventToggleWidget extends CategoryEvent{
final int widgetId;
final int categoryId;

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

@override
Expand Down
4 changes: 1 addition & 3 deletions lib/blocs/category_widget/category_widget_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ class CategoryWidgetBloc
extends Bloc<CategoryWidgetEvent, CategoryWidgetState> {
final CategoryBloc categoryBloc;

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

CategoryRepository get repository => categoryBloc.repository;

Expand Down
25 changes: 0 additions & 25 deletions lib/blocs/category_widget/category_widget_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ abstract class CategoryWidgetEvent extends Equatable{
List<Object> get props => [];
}

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

class EventLoadCategoryWidget extends CategoryWidgetEvent{
final int categoryId;

Expand All @@ -33,23 +28,3 @@ class EventToggleCategoryWidget extends CategoryWidgetEvent{
@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];
//}
2 changes: 0 additions & 2 deletions lib/blocs/collect/collect_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import 'collect_state.dart';
/// contact me by email [email protected]
/// 说明:



class CollectBloc extends Bloc<CollectEvent, CollectState> {
final WidgetRepository repository;

Expand Down
109 changes: 109 additions & 0 deletions lib/components/permanent/edit_panel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import 'package:flutter/material.dart';

typedef ChangeCallback = void Function(String str);

///输入面板
class EditPanel extends StatefulWidget {
EditPanel(
{Key key,
this.backgroundColor = Colors.white,
this.color = Colors.lightBlue,
this.minLines = 4,
this.maxLines = 15,
this.fontSize = 14,
this.submitClear = true,
this.defaultText = "",
this.onChange,
this.hint = "写点什么..."})
: super(key: key);

final Color color; //字颜色
final Color backgroundColor; //背景色颜色
final int minLines; //最小行数
final int maxLines; //最大行数
final double fontSize; //字号
final String hint; //提示字
final bool submitClear; //提交是否清空文字
final ChangeCallback onChange; //提交监听
final String defaultText; //提交监听

@override
_EditPanelState createState() => _EditPanelState();
}

class _EditPanelState extends State<EditPanel> {
var _radius; //边角半径

TextEditingController _controller;

@override
void initState() {
_radius = Radius.circular(widget.fontSize * 0.618);
_controller = TextEditingController(text: widget.defaultText??'');
super.initState();
}

@override
void dispose() {
_controller.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
var panel = TextField(
controller: _controller,
//输入控制器
keyboardType: TextInputType.text,
//键盘类型
textAlign: TextAlign.start,
//文字居左
cursorColor: Colors.black,
//游标颜色
minLines: widget.minLines,
//最小行数
maxLines: widget.maxLines,
//最大行数
style: TextStyle(
//文字样式
fontSize: widget.fontSize,
color: widget.color,
backgroundColor: Colors.white),
decoration: InputDecoration(
//装饰线
filled: true,
//是否填充
fillColor: widget.backgroundColor,
//填充色
hintText: widget.hint,
//提示文字
hintStyle: TextStyle(color: Colors.black26, fontSize: widget.fontSize),
//提示文字样式
focusedBorder: UnderlineInputBorder(
//聚焦时边线
borderSide: BorderSide(color: widget.backgroundColor),
borderRadius: BorderRadius.all(_radius),
),
enabledBorder: UnderlineInputBorder(
//非聚焦时边线
borderSide: BorderSide(color: widget.backgroundColor),
borderRadius: BorderRadius.all(_radius),
),
),
onChanged: (str) {
//文字变化监听
if (widget.onChange != null) widget.onChange(str);
},
onSubmitted: (str) {
//提交监听
FocusScope.of(context).requestFocus(FocusNode()); //收起键盘
if (widget.submitClear) {
setState(() {
_controller.clear();
});
}
},
);
return panel;
}
}
16 changes: 11 additions & 5 deletions lib/repositories/itf/category_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,31 @@ import 'package:flutter_unit/storage/po/category_po.dart';

/// create by 张风捷特烈 on 2020-04-21
/// contact me by email [email protected]
/// 说明:
/// 说明: 负责数据的存储和操作接口

abstract class CategoryRepository {

//切换一个组件在收藏夹中的状态
Future<void> toggleCategory(int categoryId, int widgetId);

// 检查一个组件是否在收藏夹内
Future<bool> check(int categoryId,int widgetId);

// 获取一个收藏夹中的所有组件
Future<List<WidgetModel>> loadCategoryWidgets({int categoryId = 0});


// 获取所有收藏集
Future<List<CategoryModel>> loadCategories();

//添加收藏集
Future<bool> addCategory(CategoryPo categoryPo);

//更新收藏集
Future<bool> updateCategory(CategoryPo categoryPo);

//删除收藏集
Future<void> deleteCategory(int id);
Future<List<int>> getCategoryByWidget(int widgetId);


//查看某个组件在哪些收藏集中
Future<List<int>> getCategoryByWidget(int widgetId);

}
6 changes: 1 addition & 5 deletions lib/repositories/itf/widget_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@ abstract class WidgetRepository {

Future<List<WidgetModel>> loadWidget(List<int> ids);


Future<List<WidgetModel>> searchWidgets(SearchArgs args);
Future<List<NodeModel>> loadNode(WidgetModel widgetModel);

Future<void> toggleCollect(int id);

Future<List<WidgetModel>> loadCollectWidgets();
Future<bool> collected(int id);




Future<bool> collected(int id);
}
116 changes: 116 additions & 0 deletions lib/views/pages/category/category_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_unit/app/router.dart';
import 'package:flutter_unit/blocs/category/category_bloc.dart';
import 'package:flutter_unit/blocs/category/category_event.dart';
import 'package:flutter_unit/blocs/category/category_state.dart';
import 'package:flutter_unit/blocs/category_widget/category_widget_bloc.dart';
import 'package:flutter_unit/blocs/category_widget/category_widget_event.dart';
import 'package:flutter_unit/blocs/widgets/home_bloc.dart';
import 'package:flutter_unit/components/permanent/circle.dart';

import 'package:flutter_unit/model/category_model.dart';
import 'package:flutter_unit/views/dialogs/delete_category_dialog.dart';
import 'package:flutter_unit/views/items/category_list_item.dart';
import 'package:flutter_unit/views/pages/category/home_right_drawer.dart';

import 'edit_category_panel.dart';

class CategoryPage extends StatelessWidget {
final gridDelegate = const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
childAspectRatio: 0.8,
);

@override
Widget build(BuildContext context) {
return BlocBuilder<CategoryBloc, CategoryState>(builder: (_, state) {
if (state is CategoryLoadedState) {
return GridView.builder(
padding: EdgeInsets.all(10),
itemCount: state.categories.length,
itemBuilder: (_, index) => Container(
child: GestureDetector(
onTap: () => _toDetailPage(context, state.categories[index]),
child: CategoryListItem(
data: state.categories[index],
onDeleteItemClick: (model) => _deleteCollect(context, model),
onEditItemClick: (model) => _editCollect(context, model),
)),
),
gridDelegate: gridDelegate,
);
}
return Container();
});
}

_deleteCollect(BuildContext context, CategoryModel model) {
showDialog(
context: context,
builder: (ctx) => Dialog(
elevation: 5,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(10))),
child: Container(
width: 50,
child: DeleteCategoryDialog(
title: '删除收藏集',
content: ' 删除【${model.name}】收藏集,你将会失去其中的所有收藏组件,是否确定继续执行?',
onSubmit: () {
BlocProvider.of<CategoryBloc>(context)
.add(EventDeleteCategory(id: model.id));
Navigator.of(context).pop();
},
),
),
));
}

_editCollect(BuildContext context, CategoryModel model) {
showDialog(
context: context,
builder: (ctx) => Dialog(
backgroundColor:Color(0xFFF2F2F2),
elevation: 5,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(10))),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(
height: 5,
),
Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(left: 20, right: 10),
child: Circle(
color: Theme.of(context).primaryColor,
),
),
Text(
'修改收藏集',
style: TextStyle(fontSize: 20),
),
Spacer(),
CloseButton()
],
),
Padding(
padding: const EdgeInsets.all(8.0),
child: EditCategoryPanel(model: model,type: EditType.update,),
),
],
),
));
}

_toDetailPage(BuildContext context, CategoryModel model) {
BlocProvider.of<CategoryWidgetBloc>(context)
.add(EventLoadCategoryWidget(model.id));
Navigator.pushNamed(context, Router.category_show, arguments: model);
}
}
Loading