/
collapsebox_example.dart
94 lines (90 loc) · 2.7 KB
/
collapsebox_example.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright (c) 2018, Marco Esposito (marcoesposito1988@gmail.com).
// Please see the AUTHORS file for details. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file.
import 'package:collapsebox/view/column_collapsebox.dart';
import 'package:collapsebox/view/custom_collapsebox.dart';
import 'package:collapsebox/vm/collapsebox_viewmodel.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
void main() {
Widget buildColumnCollapseBoxWidget() {
return ColumnCollapseBoxWidget(
// arrow image resource
bottomArrowImageRes: 'images/image_down_expand.png',
// arrow image area bg color
bottomBarColor: Colors.white,
// stretchState: StretchedBoxState.normal,// normal default
// area show always
alwaysShowChild: Container(
color: Colors.white,
child: Column(
children: [
Text("Normal Area 1"),
Text("Normal Area 2"),
Text("Normal Area 3"),
],
),
),
// area show by expand
collapsedChild: Container(
// 展开展示区域
color: Colors.black12,
child: Column(
children: [
Text("Collapse Area 1"),
Text("Collapse Area 2"),
],
),
),
// bottomBarWidget: _buildCustomBottomWidget,// bottom widget custom set
);
}
Widget buildCustomStretchedBoxWidget() {
return CollapseBoxWidget(
alwaysShowChild: Container(
color: Colors.white,
child: Column(
children: [
Text("Normal Area 1"),
Text("Normal Area 2"),
Text("Normal Area 3"),
],
),
),
collapsedChild: Container(
color: Colors.black12,
child: Column(
children: [
Text("Collapse Area 1"),
Text("Collapse Area 2"),
],
),
),
// custom bottomBar Widget set
bottomBarWidget:
(BuildContext context, CollapseboxBoxViewModel collapseboxViewModel) {
Widget text;
if (collapseboxViewModel?.isExpand() ?? false) {
text = Text("Click Collapse");
} else {
text = Text("Click Expand");
}
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
collapseboxViewModel?.switchCollapseBoxMode();
},
child: Container(
height: 32,
width: double.infinity,
color: Colors.deepPurpleAccent,
child: Center(
child: text,
),
),
);
}, // 自定义底部Widget方式
);
}
}