forked from bdlukaa/fluent_ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathothers.dart
255 lines (238 loc) · 8.25 KB
/
others.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
// ignore_for_file: avoid_print
import 'package:fluent_ui/fluent_ui.dart';
class Others extends StatefulWidget {
const Others({Key? key}) : super(key: key);
@override
_OthersState createState() => _OthersState();
}
class _OthersState extends State<Others> {
final otherController = ScrollController();
int currentIndex = 0;
final flyoutController = FlyoutController();
bool checked = false;
@override
void dispose() {
flyoutController.dispose();
otherController.dispose();
super.dispose();
}
DateTime date = DateTime.now();
late List<Tab> tabs;
@override
void initState() {
super.initState();
tabs = List.generate(3, (index) {
late Tab tab;
tab = Tab(
text: Text('$index'),
onClosed: () {
_handleTabClosed(tab);
},
);
return tab;
});
}
@override
Widget build(BuildContext context) {
return ScaffoldPage(
header: const PageHeader(title: Text('Others')),
content: ListView(
padding: EdgeInsets.only(
bottom: kPageDefaultVerticalPadding,
left: PageHeader.horizontalPadding(context),
right: PageHeader.horizontalPadding(context),
),
controller: otherController,
children: [
...List.generate(InfoBarSeverity.values.length, (index) {
final severity = InfoBarSeverity.values[index];
final titles = [
'Long title',
'Short title',
];
final descs = [
'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book',
'Short desc',
];
return Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: InfoBar(
title: Text(titles[index.isEven ? 0 : 1]),
content: Text(descs[index.isEven ? 0 : 1]),
isLong: InfoBarSeverity.values.indexOf(severity).isEven,
severity: severity,
action: () {
if (index == 0) {
return Tooltip(
message: 'This is a tooltip',
child: Button(
child: const Text('Hover this button to see a tooltip'),
onPressed: () {
print('pressed button with tooltip');
},
),
);
} else {
if (index == 3) {
return Flyout(
controller: flyoutController,
contentWidth: 450,
content: const FlyoutContent(
child: Text(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.'),
),
child: Button(
child: const Text('Open flyout'),
onPressed: () {
flyoutController.open = true;
},
),
);
}
}
}(),
onClose: () {
print('closed');
},
),
);
}),
Wrap(children: [
const ListTile(
title: Text('ListTile Title'),
subtitle: Text('ListTile Subtitle'),
),
TappableListTile(
leading: const CircleAvatar(),
title: const Text('TappableListTile Title'),
subtitle: const Text('TappableListTile Subtitle'),
onTap: () {
print('tapped tappable list tile');
},
),
]),
Row(children: const [
Padding(
padding: EdgeInsets.all(6),
child: ProgressBar(value: 50),
),
Padding(
padding: EdgeInsets.all(10),
child: ProgressRing(value: 85),
),
Padding(
padding: EdgeInsets.all(6),
child: ProgressBar(),
),
Padding(
padding: EdgeInsets.all(10),
child: ProgressRing(),
),
]),
// Row(children: [
// CalendarView(
// onDateChanged: _handleDateChanged,
// firstDate: DateTime.now().subtract(Duration(days: 365 * 100)),
// lastDate: DateTime.now().add(Duration(days: 365 * 100)),
// initialDate: date,
// currentDate: date,
// onDisplayedMonthChanged: (date) {
// setState(() => this.date = date);
// },
// ),
// CalendarView(
// onDateChanged: _handleDateChanged,
// firstDate: DateTime.now().subtract(Duration(days: 365 * 100)),
// lastDate: DateTime.now().add(Duration(days: 365 * 100)),
// initialDate: date,
// currentDate: date,
// onDisplayedMonthChanged: (date) {
// setState(() => this.date = date);
// },
// initialCalendarMode: DatePickerMode.year,
// ),
// ]),
const SizedBox(height: 10),
Container(
height: 400,
decoration: BoxDecoration(
border: Border.all(
color: FluentTheme.of(context).accentColor, width: 1.0),
),
child: TabView(
currentIndex: currentIndex,
onChanged: _handleTabChanged,
onReorder: (oldIndex, newIndex) {
setState(() {
if (oldIndex < newIndex) {
newIndex -= 1;
}
final Tab item = tabs.removeAt(oldIndex);
tabs.insert(newIndex, item);
if (currentIndex == newIndex) {
currentIndex = oldIndex;
} else if (currentIndex == oldIndex) {
currentIndex = newIndex;
}
});
},
onNewPressed: () {
setState(() {
late Tab tab;
tab = Tab(
text: Text('${tabs.length}'),
onClosed: () {
_handleTabClosed(tab);
},
);
tabs.add(tab);
});
},
tabs: tabs,
bodies: List.generate(
tabs.length,
(index) => Container(
color: Colors.accentColors[index.clamp(
0,
Colors.accentColors.length - 1,
)],
child: Stack(children: [
const Positioned.fill(child: FlutterLogo()),
Align(
alignment: Alignment.center,
child: SizedBox(
width: 250.0,
height: 200.0,
child: Acrylic(
child: Center(
child: Text(
'A C R Y L I C',
style:
FluentTheme.of(context).typography.titleLarge,
textAlign: TextAlign.center,
),
),
),
),
),
]),
),
),
),
),
],
),
);
}
void _handleTabChanged(int index) {
setState(() => currentIndex = index);
}
void _handleTabClosed(Tab tab) {
setState(() {
tabs.remove(tab);
if (currentIndex > tabs.length - 1) currentIndex--;
});
}
// void _handleDateChanged(DateTime date) {
// }
}