11import 'package:flutter/material.dart' ;
2- import 'package:flutter_mobile_2school/src/themes/app_colors.dart' ;
3- import 'package:flutter_mobile_2school/src/themes/font_family.dart' ;
42import 'package:flutter_mobile_2school/src/ui/home/widgets/date_bar.dart' ;
53import 'package:sizer/sizer.dart' ;
6- import 'package:timelines/timelines.dart' ;
74
85class CalendarScreen extends StatefulWidget {
96 @override
@@ -21,274 +18,10 @@ class _CalendarScreenState extends State<CalendarScreen> {
2118 SizedBox (height: 16. sp),
2219 DateBarPicker (),
2320 SizedBox (height: 4. sp),
24- ListView .builder (
25- padding: EdgeInsets .symmetric (vertical: 16. sp),
26- physics: NeverScrollableScrollPhysics (),
27- shrinkWrap: true ,
28- itemCount: 1 ,
29- itemBuilder: (context, index) {
30- final data = _data (index + 1 );
31- return Container (
32- color: Colors .transparent,
33- child: Column (
34- mainAxisSize: MainAxisSize .min,
35- children: [
36- Padding (
37- padding: EdgeInsets .symmetric (horizontal: 14. sp),
38- child: _OrderTitle (
39- orderInfo: data,
40- ),
41- ),
42- _DeliveryProcesses (processes: data.deliveryProcesses),
43- ],
44- ),
45- );
46- },
47- ),
4821 ],
4922 ),
5023 ),
5124 ),
5225 );
5326 }
5427}
55-
56- class _OrderTitle extends StatelessWidget {
57- const _OrderTitle ({
58- Key ? key,
59- required this .orderInfo,
60- }) : super (key: key);
61-
62- final _OrderInfo orderInfo;
63-
64- @override
65- Widget build (BuildContext context) {
66- return Row (
67- children: [
68- Text (
69- 'Deadlines' ,
70- style: TextStyle (
71- fontWeight: FontWeight .w600,
72- fontFamily: FontFamily .lato,
73- fontSize: 12. sp,
74- color: Theme .of (context).textTheme.bodyText2! .color,
75- ),
76- ),
77- Spacer (),
78- Text (
79- '${orderInfo .date .day }/${orderInfo .date .month }/${orderInfo .date .year }' ,
80- style: TextStyle (
81- color:
82- Theme .of (context).textTheme.bodyText2! .color! .withOpacity (.75 ),
83- ),
84- ),
85- ],
86- );
87- }
88- }
89-
90- class _InnerTimeline extends StatelessWidget {
91- const _InnerTimeline ({
92- required this .messages,
93- });
94-
95- final List <_DeliveryMessage > messages;
96-
97- @override
98- Widget build (BuildContext context) {
99- bool isEdgeIndex (int index) {
100- return index == 0 || index == messages.length + 1 ;
101- }
102-
103- return Padding (
104- padding: const EdgeInsets .symmetric (vertical: 8.0 ),
105- child: FixedTimeline .tileBuilder (
106- theme: TimelineTheme .of (context).copyWith (
107- nodePosition: 0 ,
108- connectorTheme: TimelineTheme .of (context).connectorTheme.copyWith (
109- thickness: 1.0 ,
110- color: colorGreenLight,
111- ),
112- indicatorTheme: TimelineTheme .of (context).indicatorTheme.copyWith (
113- size: 10.0 ,
114- position: 0.5 ,
115- color: colorGreenLight,
116- ),
117- ),
118- builder: TimelineTileBuilder (
119- indicatorBuilder: (_, index) =>
120- ! isEdgeIndex (index) ? Indicator .outlined (borderWidth: 1.0 ) : null ,
121- startConnectorBuilder: (_, index) => Connector .solidLine (),
122- endConnectorBuilder: (_, index) => Connector .solidLine (),
123- contentsBuilder: (_, index) {
124- if (isEdgeIndex (index)) {
125- return null ;
126- }
127-
128- return Padding (
129- padding: EdgeInsets .only (left: 8.0 ),
130- child: Text (messages[index - 1 ].toString ()),
131- );
132- },
133- itemExtentBuilder: (_, index) => isEdgeIndex (index) ? 10.0 : 30.0 ,
134- nodeItemOverlapBuilder: (_, index) =>
135- isEdgeIndex (index) ? true : null ,
136- itemCount: messages.length + 2 ,
137- ),
138- ),
139- );
140- }
141- }
142-
143- class _DeliveryProcesses extends StatelessWidget {
144- const _DeliveryProcesses ({Key ? key, required this .processes})
145- : super (key: key);
146-
147- final List <_DeliveryProcess > processes;
148- @override
149- Widget build (BuildContext context) {
150- return DefaultTextStyle (
151- style: TextStyle (
152- color: Color (0xff9b9b9b ),
153- fontSize: 12.5 ,
154- ),
155- child: Padding (
156- padding: const EdgeInsets .all (20.0 ),
157- child: FixedTimeline .tileBuilder (
158- theme: TimelineThemeData (
159- nodePosition: 0 ,
160- color: Color (0xff989898 ),
161- indicatorTheme: IndicatorThemeData (
162- position: 0 ,
163- size: 20.0 ,
164- ),
165- connectorTheme: ConnectorThemeData (
166- thickness: 2.5 ,
167- ),
168- ),
169- builder: TimelineTileBuilder .connected (
170- connectionDirection: ConnectionDirection .before,
171- itemCount: processes.length,
172- contentsBuilder: (_, index) {
173- if (processes[index].isCompleted) return null ;
174-
175- return Padding (
176- padding: EdgeInsets .only (left: 8.0 ),
177- child: Column (
178- crossAxisAlignment: CrossAxisAlignment .start,
179- mainAxisSize: MainAxisSize .min,
180- children: [
181- Text (
182- processes[index].name,
183- style: DefaultTextStyle .of (context).style.copyWith (
184- fontSize: 18.0 ,
185- ),
186- ),
187- _InnerTimeline (messages: processes[index].messages),
188- ],
189- ),
190- );
191- },
192- indicatorBuilder: (_, index) {
193- if (processes[index].isCompleted) {
194- return DotIndicator (
195- color: Color (0xff66c97f ),
196- child: Icon (
197- Icons .check,
198- color: Colors .white,
199- size: 12.0 ,
200- ),
201- );
202- } else {
203- return OutlinedDotIndicator (
204- borderWidth: 2.5 ,
205- );
206- }
207- },
208- connectorBuilder: (_, index, ___) => SolidLineConnector (
209- color: processes[index].isCompleted ? Color (0xff66c97f ) : null ,
210- ),
211- ),
212- ),
213- ),
214- );
215- }
216- }
217-
218- _OrderInfo _data (int id) => _OrderInfo (
219- id: id,
220- date: DateTime .now (),
221- deliveryProcesses: [
222- _DeliveryProcess (
223- 'Flutter' ,
224- messages: [
225- _DeliveryMessage ('11:30AM' , 'Online Exam' ),
226- ],
227- ),
228- _DeliveryProcess (
229- 'Javascript' ,
230- messages: [
231- _DeliveryMessage ('13:00PM' , 'Online Exam' ),
232- ],
233- ),
234- _DeliveryProcess (
235- 'Java' ,
236- messages: [
237- _DeliveryMessage ('13:00PM' , 'Online Exam' ),
238- ],
239- ),
240- _DeliveryProcess (
241- 'OOP' ,
242- messages: [
243- _DeliveryMessage ('13:00PM' , 'Online Exam' ),
244- ],
245- ),
246- _DeliveryProcess (
247- 'Database' ,
248- messages: [
249- _DeliveryMessage ('13:00PM' , 'Online Exam' ),
250- ],
251- ),
252- _DeliveryProcess .complete (),
253- ],
254- );
255-
256- class _OrderInfo {
257- const _OrderInfo ({
258- required this .id,
259- required this .date,
260- required this .deliveryProcesses,
261- });
262-
263- final int id;
264- final DateTime date;
265- final List <_DeliveryProcess > deliveryProcesses;
266- }
267-
268- class _DeliveryProcess {
269- const _DeliveryProcess (
270- this .name, {
271- this .messages = const [],
272- });
273-
274- const _DeliveryProcess .complete ()
275- : this .name = 'Done' ,
276- this .messages = const [];
277-
278- final String name;
279- final List <_DeliveryMessage > messages;
280-
281- bool get isCompleted => name == 'Done' ;
282- }
283-
284- class _DeliveryMessage {
285- const _DeliveryMessage (this .createdAt, this .message);
286-
287- final String createdAt; // final DateTime createdAt;
288- final String message;
289-
290- @override
291- String toString () {
292- return '$createdAt $message ' ;
293- }
294- }
0 commit comments