Skip to content

Commit be46774

Browse files
committed
收藏集静态界面
1 parent 13c575b commit be46774

29 files changed

+1042
-156
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
### FlutterUnit apk 下载体验:
66

77

8-
![](https://user-gold-cdn.xitu.io/2020/4/19/17190f04f947005c?w=300&h=390&f=png&s=23016)
8+
![](https://user-gold-cdn.xitu.io/2020/4/19/171930c288fc7de5?w=300&h=390&f=png&s=22671)
99

1010
---
1111

assets/flutter.db

0 Bytes
Binary file not shown.

lib/app/router.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_unit/views/pages/about/about_me_page.dart';
33
import 'package:flutter_unit/views/pages/about/about_app_page.dart';
4+
import 'package:flutter_unit/views/pages/collect/default_collect_page.dart';
45
import 'package:flutter_unit/views/pages/search/serach_page.dart';
56
import 'package:flutter_unit/views/pages/setting/code_style_setting.dart';
67
import 'package:flutter_unit/views/pages/setting/font_setting.dart';
@@ -47,7 +48,7 @@ class Router {
4748
case search:
4849
return Right2LeftRouter(child: SearchPage());
4950
case collect:
50-
return Right2LeftRouter(child: CollectPage());
51+
return Right2LeftRouter(child: DefaultCollectPage());
5152
case nav:
5253
return Left2RightRouter(child: UnitNavigation());
5354
case setting:

lib/app/style/unit_color.dart

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import 'package:flutter/material.dart';
2+
3+
/// create by 张风捷特烈 on 2020-04-19
4+
/// contact me by email [email protected]
5+
/// 说明:
6+
7+
class UnitColor {
8+
static const collectColorSupport = <Color>[
9+
Color(0xFFF2F2F2),
10+
Colors.black,
11+
Colors.red,
12+
Colors.orange,
13+
Colors.yellow,
14+
Colors.green,
15+
Colors.blue,
16+
Colors.indigo,
17+
Colors.purple,
18+
19+
Colors.cyanAccent,
20+
Color(0xffd1d08f),
21+
Colors.pink,
22+
Colors.amber,
23+
Colors.lime,
24+
Colors.teal,
25+
Colors.cyan,
26+
Color(0xff586CF2),
27+
Colors.purpleAccent,
28+
];
29+
}

lib/app/style/unit_text_style.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import 'package:flutter/cupertino.dart';
2+
import 'package:flutter/material.dart';
3+
4+
/// create by 张风捷特烈 on 2020-04-19
5+
/// contact me by email [email protected]
6+
/// 说明:
7+
//
8+
//class UnitTextStyle {
9+
// static TextStyle withSizeColor(double fontSize, Color color) =>
10+
// TextStyle(fontSize: 16, color: color);
11+
//
12+
// static TextStyle title() =>
13+
// withSizeColor(16,Colors.black);
14+
//
15+
// static TextStyle titleTheme(BuildContext context) =>
16+
// withSizeColor(16, Theme.of(context).primaryColor);
17+
//}

lib/blocs/collect/collect_bloc.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:equatable/equatable.dart';
22
import 'package:flutter/cupertino.dart';
33
import 'package:flutter_bloc/flutter_bloc.dart';
4-
import 'package:flutter_unit/storage/widget_dao.dart';
4+
import 'package:flutter_unit/storage/dao/widget_dao.dart';
55
import 'package:flutter_unit/repositorys/widget_repository.dart';
66

77
import 'collect_event.dart';
@@ -28,10 +28,13 @@ class CollectBloc extends Bloc<CollectEvent, CollectState> {
2828
if (event is ToggleCollectEvent) {
2929
await repository.toggleCollect(event.id);
3030
final widgets = await repository.loadCollectWidgets();
31+
3132
yield CollectState(widgets: widgets);
3233
}
3334
if( event is EventSetCollectData){
3435
final widgets = await repository.loadCollectWidgets();
36+
final collect = await repository.loadCollects();
37+
print(collect);
3538
yield CollectState(widgets: widgets);
3639
}
3740
}

lib/blocs/search/search_event.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
import 'package:flutter_unit/storage/widget_dao.dart';
3+
import 'package:flutter_unit/storage/dao/widget_dao.dart';
44

55
abstract class SearchEvent{//事件基
66
const SearchEvent();
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
// Copyright 2017 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter/material.dart';
6+
import 'package:flutter/widgets.dart';
7+
8+
9+
const Duration _kExpand = Duration(milliseconds: 200);
10+
11+
/// A single-line [ListTile] with a trailing button that expands or collapses
12+
/// the tile to reveal or hide the [children].
13+
///
14+
/// This widget is typically used with [ListView] to create an
15+
/// "expand / collapse" list entry. When used with scrolling widgets like
16+
/// [ListView], a unique [PageStorageKey] must be specified to enable the
17+
/// [NoBorderExpansionTile] to save and restore its expanded state when it is scrolled
18+
/// in and out of view.
19+
///
20+
/// See also:
21+
///
22+
/// * [ListTile], useful for creating expansion tile [children] when the
23+
/// expansion tile represents a sublist.
24+
/// * The "Expand/collapse" section of
25+
/// <https://material.io/guidelines/components/lists-controls.html>.
26+
class NoBorderExpansionTile extends StatefulWidget {
27+
/// Creates a single-line [ListTile] with a trailing button that expands or collapses
28+
/// the tile to reveal or hide the [children]. The [initiallyExpanded] property must
29+
/// be non-null.
30+
const NoBorderExpansionTile({
31+
Key key,
32+
this.leading,
33+
@required this.title,
34+
this.subtitle,
35+
this.backgroundColor,
36+
this.onExpansionChanged,
37+
this.children = const <Widget>[],
38+
this.trailing,
39+
this.initiallyExpanded = false,
40+
}) : assert(initiallyExpanded != null),
41+
super(key: key);
42+
43+
/// A widget to display before the title.
44+
///
45+
/// Typically a [CircleAvatar] widget.
46+
final Widget leading;
47+
48+
/// The primary content of the list item.
49+
///
50+
/// Typically a [Text] widget.
51+
final Widget title;
52+
53+
/// Additional content displayed below the title.
54+
///
55+
/// Typically a [Text] widget.
56+
final Widget subtitle;
57+
58+
/// Called when the tile expands or collapses.
59+
///
60+
/// When the tile starts expanding, this function is called with the value
61+
/// true. When the tile starts collapsing, this function is called with
62+
/// the value false.
63+
final ValueChanged<bool> onExpansionChanged;
64+
65+
/// The widgets that are displayed when the tile expands.
66+
///
67+
/// Typically [ListTile] widgets.
68+
final List<Widget> children;
69+
70+
/// The color to display behind the sublist when expanded.
71+
final Color backgroundColor;
72+
73+
/// A widget to display instead of a rotating arrow icon.
74+
final Widget trailing;
75+
76+
/// Specifies if the list tile is initially expanded (true) or collapsed (false, the default).
77+
final bool initiallyExpanded;
78+
79+
@override
80+
_NoBorderExpansionTileState createState() => _NoBorderExpansionTileState();
81+
}
82+
83+
class _NoBorderExpansionTileState extends State<NoBorderExpansionTile> with SingleTickerProviderStateMixin {
84+
static final Animatable<double> _easeOutTween = CurveTween(curve: Curves.easeOut);
85+
static final Animatable<double> _easeInTween = CurveTween(curve: Curves.easeIn);
86+
static final Animatable<double> _halfTween = Tween<double>(begin: 0.0, end: 0.5);
87+
88+
final ColorTween _borderColorTween = ColorTween();
89+
final ColorTween _headerColorTween = ColorTween();
90+
final ColorTween _iconColorTween = ColorTween();
91+
final ColorTween _backgroundColorTween = ColorTween();
92+
93+
AnimationController _controller;
94+
Animation<double> _iconTurns;
95+
Animation<double> _heightFactor;
96+
Animation<Color> _borderColor;
97+
Animation<Color> _headerColor;
98+
Animation<Color> _iconColor;
99+
Animation<Color> _backgroundColor;
100+
101+
bool _isExpanded = false;
102+
103+
@override
104+
void initState() {
105+
super.initState();
106+
_controller = AnimationController(duration: _kExpand, vsync: this);
107+
_heightFactor = _controller.drive(_easeInTween);
108+
_iconTurns = _controller.drive(_halfTween.chain(_easeInTween));
109+
_borderColor = _controller.drive(_borderColorTween.chain(_easeOutTween));
110+
_headerColor = _controller.drive(_headerColorTween.chain(_easeInTween));
111+
_iconColor = _controller.drive(_iconColorTween.chain(_easeInTween));
112+
_backgroundColor = _controller.drive(_backgroundColorTween.chain(_easeOutTween));
113+
114+
_isExpanded = PageStorage.of(context)?.readState(context) ?? widget.initiallyExpanded;
115+
if (_isExpanded)
116+
_controller.value = 1.0;
117+
}
118+
119+
120+
@override
121+
void dispose() {
122+
_controller.dispose();
123+
super.dispose();
124+
}
125+
126+
void _handleTap() {
127+
setState(() {
128+
_isExpanded = !_isExpanded;
129+
if (_isExpanded) {
130+
_controller.forward();
131+
} else {
132+
_controller.reverse().then<void>((void value) {
133+
if (!mounted)
134+
return;
135+
setState(() {
136+
// Rebuild without widget.children.
137+
});
138+
});
139+
}
140+
PageStorage.of(context)?.writeState(context, _isExpanded);
141+
});
142+
if (widget.onExpansionChanged != null)
143+
widget.onExpansionChanged(_isExpanded);
144+
}
145+
146+
Widget _buildChildren(BuildContext context, Widget child) {
147+
148+
return Container(
149+
color: _backgroundColor.value ?? Colors.transparent,
150+
child: Column(
151+
mainAxisSize: MainAxisSize.min,
152+
children: <Widget>[
153+
ListTileTheme.merge(
154+
iconColor: _iconColor.value,
155+
textColor: _headerColor.value,
156+
child: ListTile(
157+
onTap: _handleTap,
158+
leading: widget.leading,
159+
title: widget.title,
160+
subtitle: widget.subtitle,
161+
trailing: widget.trailing ?? RotationTransition(
162+
turns: _iconTurns,
163+
child: const Icon(Icons.expand_more),
164+
),
165+
),
166+
),
167+
ClipRect(
168+
child: Align(
169+
// alignment: Alignment.topCenter,
170+
heightFactor: _heightFactor.value,
171+
child: child,
172+
),
173+
),
174+
],
175+
),
176+
);
177+
}
178+
179+
@override
180+
void didChangeDependencies() {
181+
final ThemeData theme = Theme.of(context);
182+
_borderColorTween
183+
..end = theme.dividerColor;
184+
_headerColorTween
185+
..begin = theme.textTheme.subhead.color
186+
..end = theme.accentColor;
187+
_iconColorTween
188+
..begin = theme.unselectedWidgetColor
189+
..end = theme.accentColor;
190+
_backgroundColorTween
191+
..end = widget.backgroundColor;
192+
super.didChangeDependencies();
193+
}
194+
195+
@override
196+
Widget build(BuildContext context) {
197+
final bool closed = !_isExpanded && _controller.isDismissed;
198+
return AnimatedBuilder(
199+
animation: _controller.view,
200+
builder: _buildChildren,
201+
child: closed ? null : Column(children: widget.children),
202+
);
203+
204+
}
205+
}

0 commit comments

Comments
 (0)