@@ -5,16 +5,17 @@ import 'MaterialIconsSelected.dart';
5
5
import 'main.dart' ;
6
6
import 'utils.dart' ;
7
7
8
- class StudySpacePage extends StatelessWidget {
9
- const StudySpacePage ({Key ? key, required this .studySpace}) : super (key: key);
8
+ class OpeningHourCard extends StatelessWidget {
9
+ const OpeningHourCard ({Key ? key, required this .openingHours})
10
+ : super (key: key);
10
11
11
- final StudySpace studySpace ;
12
+ final List < OpeningHours > openingHours ;
12
13
13
14
@override
14
15
Widget build (BuildContext context) {
15
- DateTime today = DateTime .now ();
16
16
List <Widget > hoursList = [];
17
- hoursList.addAll (studySpace.openingHours.mapIndexed ((index, hours) {
17
+ DateTime today = DateTime .now ();
18
+ hoursList.addAll (openingHours.mapIndexed ((index, hours) {
18
19
var day = today.add (Duration (days: index));
19
20
return Container (
20
21
decoration: BoxDecoration (
@@ -44,6 +45,93 @@ class StudySpacePage extends StatelessWidget {
44
45
style: Theme .of (context).textTheme.titleLarge)),
45
46
]));
46
47
}));
48
+ return Card (
49
+ margin: EdgeInsets .zero,
50
+ child: Padding (
51
+ padding: EdgeInsets .all (
52
+ Theme .of (context).textTheme.bodyLarge! .fontSize! ),
53
+ child:
54
+ Column (crossAxisAlignment: CrossAxisAlignment .start, children: [
55
+ Text ("Opening Hours" ,
56
+ style: Theme .of (context).textTheme.headlineSmall),
57
+ SizedBox (
58
+ height:
59
+ Theme .of (context).textTheme.headlineSmall! .fontSize! / 2 ),
60
+ ListView .separated (
61
+ shrinkWrap: true ,
62
+ itemCount: hoursList.length,
63
+ itemBuilder: (BuildContext context, int index) {
64
+ return hoursList[index];
65
+ },
66
+ separatorBuilder: (context, index) => SizedBox (
67
+ height: Theme .of (context).textTheme.bodySmall! .fontSize! / 2 ,
68
+ ),
69
+
70
+ // itemExtent: 100,
71
+ )
72
+ ])));
73
+ }
74
+ }
75
+
76
+ class AreasCard extends StatelessWidget {
77
+ const AreasCard ({Key ? key, required this .areas}) : super (key: key);
78
+
79
+ final List <Area > areas;
80
+
81
+ @override
82
+ Widget build (BuildContext context) {
83
+ return Expanded (
84
+ child: ListView .separated (
85
+ scrollDirection: Axis .horizontal,
86
+ itemCount: areas.length,
87
+ itemBuilder: (BuildContext context, int index) => Card (
88
+ margin: EdgeInsets .zero,
89
+ child: Padding (
90
+ padding: EdgeInsets .all (
91
+ Theme .of (context).textTheme.bodyLarge! .fontSize! ),
92
+ child: Column (
93
+ crossAxisAlignment: CrossAxisAlignment .start,
94
+ children: [
95
+ Text (
96
+ areas[index].title,
97
+ style: Theme .of (context).textTheme.titleLarge,
98
+ textAlign: TextAlign .left,
99
+ ),
100
+ SizedBox (
101
+ height:
102
+ Theme .of (context).textTheme.bodyMedium! .fontSize! /
103
+ 2 ),
104
+ Text (
105
+ "Floor: ${areas [index ].floor }" ,
106
+ style: Theme .of (context).textTheme.bodyLarge,
107
+ ),
108
+ SizedBox (
109
+ height:
110
+ Theme .of (context).textTheme.headlineSmall! .fontSize! /
111
+ 2 ),
112
+ Image .asset (
113
+ areas[index].pictureUrl,
114
+ width: MediaQuery .of (context).size.width * 0.7 ,
115
+ fit: BoxFit .fitHeight,
116
+ ),
117
+ ],
118
+ ),
119
+ )),
120
+ separatorBuilder: (context, index) => SizedBox (
121
+ width: Theme .of (context).textTheme.bodySmall! .fontSize! / 2 ,
122
+ ),
123
+ ),
124
+ );
125
+ }
126
+ }
127
+
128
+ class StudySpacePage extends StatelessWidget {
129
+ const StudySpacePage ({Key ? key, required this .studySpace}) : super (key: key);
130
+
131
+ final StudySpace studySpace;
132
+
133
+ @override
134
+ Widget build (BuildContext context) {
47
135
return Scaffold (
48
136
appBar: AppBar (
49
137
leading: TextButton .icon (
@@ -63,7 +151,8 @@ class StudySpacePage extends StatelessWidget {
63
151
padding:
64
152
EdgeInsets .all (Theme .of (context).textTheme.bodyLarge! .fontSize! ),
65
153
child: Column (
66
- crossAxisAlignment: CrossAxisAlignment .center,
154
+ crossAxisAlignment: CrossAxisAlignment .stretch,
155
+ mainAxisSize: MainAxisSize .min,
67
156
children: [
68
157
Text (
69
158
studySpace.title,
@@ -73,39 +162,28 @@ class StudySpacePage extends StatelessWidget {
73
162
SizedBox (
74
163
height:
75
164
Theme .of (context).textTheme.headlineSmall! .fontSize! / 2 ),
76
- Card (
77
- child: Padding (
78
- padding: EdgeInsets .all (
79
- Theme .of (context).textTheme.bodyLarge! .fontSize! ),
80
- child: Column (
81
- crossAxisAlignment: CrossAxisAlignment .start,
82
- children: [
83
- Text ("Opening Hours" ,
84
- style:
85
- Theme .of (context).textTheme.headlineSmall),
86
- SizedBox (
87
- height: Theme .of (context)
88
- .textTheme
89
- .headlineSmall!
90
- .fontSize! /
91
- 2 ),
92
- ListView .separated (
93
- shrinkWrap: true ,
94
- itemCount: hoursList.length,
95
- itemBuilder: (BuildContext context, int index) {
96
- return hoursList[index];
97
- },
98
- separatorBuilder: (context, index) => SizedBox (
99
- height: Theme .of (context)
100
- .textTheme
101
- .bodySmall!
102
- .fontSize! /
103
- 2 ,
104
- ),
105
-
106
- // itemExtent: 100,
107
- )
108
- ]))),
165
+ OpeningHourCard (openingHours: studySpace.openingHours),
166
+ SizedBox (
167
+ height:
168
+ Theme .of (context).textTheme.headlineSmall! .fontSize! / 2 ),
169
+ Visibility (
170
+ visible: studySpace.areas.isNotEmpty,
171
+ child: Text (
172
+ "Areas" ,
173
+ style: Theme .of (context).textTheme.headlineSmall,
174
+ textAlign: TextAlign .start,
175
+ ),
176
+ ),
177
+ Visibility (
178
+ visible: studySpace.areas.isNotEmpty,
179
+ child: SizedBox (
180
+ height:
181
+ Theme .of (context).textTheme.headlineSmall! .fontSize! /
182
+ 2 ),
183
+ ),
184
+ Visibility (
185
+ visible: studySpace.areas.isNotEmpty,
186
+ child: AreasCard (areas: studySpace.areas)),
109
187
],
110
188
),
111
189
));
0 commit comments