@@ -7,8 +7,8 @@ import 'package:geolocator/geolocator.dart';
7
7
import 'package:google_fonts/google_fonts.dart' ;
8
8
import 'package:json_api/client.dart' ;
9
9
import 'package:json_api/routing.dart' ;
10
- import 'package:mstudy/studySpaceList .dart' as study_space_list ;
11
- import 'package:mstudy/studySpacePage .dart' ;
10
+ import 'package:mstudy/buildingList .dart' as building_list ;
11
+ import 'package:mstudy/buildingPage .dart' ;
12
12
import 'package:shared_preferences/shared_preferences.dart' ;
13
13
import 'package:string_similarity/string_similarity.dart' ;
14
14
import 'package:time_range_picker/time_range_picker.dart'
@@ -20,7 +20,7 @@ import 'utils.dart';
20
20
part 'main.freezed.dart' ;
21
21
part 'main.g.dart' ;
22
22
23
- /// Opening hours of a study space
23
+ /// Opening hours of a building
24
24
///
25
25
/// Can be all day, a range from start time to end time, or closed
26
26
@freezed
@@ -58,8 +58,8 @@ class AppState with _$AppState {
58
58
///
59
59
/// An [id] is used to incorporate hours fetched from M Library API.
60
60
/// Titles are not stored in the relationships of JSON:API so [id] s
61
- /// are the only way to find and match opening hours to study spaces .
62
- /// Each [HoursType] of a study space has a unique [id] .
61
+ /// are the only way to find and match opening hours to buildings .
62
+ /// Each [HoursType] of a building has a unique [id] .
63
63
@JsonSerializable (explicitToJson: true )
64
64
class OpeningDateAndHours {
65
65
late String id;
@@ -81,14 +81,14 @@ class OpeningDateAndHours {
81
81
/// Type of [OpeningDateAndHours] specified in JSON:API, e.g. "paragraph--hours_exceptions"
82
82
typedef HoursType = String ;
83
83
84
- /// Title of study spaces
84
+ /// Title of buildings
85
85
typedef SpaceTitle = String ;
86
86
87
- /// Unprocessed [OpeningDateAndHours] for each study space , organized by [HoursType]
87
+ /// Unprocessed [OpeningDateAndHours] for each building , organized by [HoursType]
88
88
typedef FieldOpeningHours
89
89
= Map <HoursType , Map <SpaceTitle , List <OpeningDateAndHours >>>;
90
90
91
- /// Processed [OpeningDateAndHours] for each study space , listed in decreasing priorities.
91
+ /// Processed [OpeningDateAndHours] for each building , listed in decreasing priorities.
92
92
/// Priorities cf processFieldOpeningHours.
93
93
typedef ProcessedOpeningHours = Map <SpaceTitle , List <OpeningDateAndHours >>;
94
94
@@ -170,7 +170,7 @@ class MyApp extends StatelessWidget {
170
170
foregroundColor: MaterialStateProperty .resolveWith ((_) => blueColor),
171
171
)));
172
172
return MaterialApp (
173
- title: 'Study spaces ' ,
173
+ title: 'Buildings ' ,
174
174
theme: theme,
175
175
home: const MyHomePage (title: 'Opening Now' ),
176
176
);
@@ -207,7 +207,7 @@ class Area {
207
207
208
208
Id getAreaId (Id buildingId, Id areaId) => "${buildingId }_$areaId " ;
209
209
210
- class StudySpace {
210
+ class Building {
211
211
final String title;
212
212
final String id;
213
213
List <OpeningHours >
@@ -218,7 +218,7 @@ class StudySpace {
218
218
final bool connectedToMLibraryApi;
219
219
final List <Area > areas;
220
220
221
- StudySpace ({
221
+ Building ({
222
222
required this .title,
223
223
required this .id,
224
224
required this .openingHours,
@@ -253,15 +253,15 @@ class _MyHomePageState extends State<MyHomePage> {
253
253
ProcessedOpeningHours openingHours = {};
254
254
TimeOfDay filterStartTime = const TimeOfDay (hour: 9 , minute: 0 );
255
255
TimeOfDay filterEndTime = const TimeOfDay (hour: 22 , minute: 0 );
256
- List <StudySpace > studySpaces = study_space_list.studySpaces ;
256
+ List <Building > buildings = building_list.buildings ;
257
257
258
258
@override
259
259
void initState () {
260
260
super .initState ();
261
261
if (kDebugMode) {
262
262
getCurrentPosition ().then ((position) {
263
263
print ("Current position is $position " );
264
- for (var space in studySpaces ) {
264
+ for (var space in buildings ) {
265
265
var distance = Geolocator .distanceBetween (
266
266
position.latitude,
267
267
position.longitude,
@@ -328,7 +328,7 @@ class _MyHomePageState extends State<MyHomePage> {
328
328
});
329
329
}
330
330
331
- /// Update the opening hours for the next 7 days of all study spaces
331
+ /// Update the opening hours for the next 7 days of all buildings
332
332
/// connected to the M library API
333
333
void updateOpeningHoursForNextSevenDays () {
334
334
List <DateTime > nextSevenDays = [];
@@ -338,9 +338,7 @@ class _MyHomePageState extends State<MyHomePage> {
338
338
nextDay = nextDay.add (const Duration (days: 1 ));
339
339
}
340
340
setState (() {
341
- studySpaces
342
- .where ((space) => space.connectedToMLibraryApi)
343
- .forEach ((space) {
341
+ buildings.where ((space) => space.connectedToMLibraryApi).forEach ((space) {
344
342
for (var day in nextSevenDays) {
345
343
var newOpeningHours = getOpeningHours (space.title, day);
346
344
if (kDebugMode) {
@@ -356,8 +354,8 @@ class _MyHomePageState extends State<MyHomePage> {
356
354
@override
357
355
Widget build (BuildContext context) {
358
356
var wordBoundary = RegExp (r'\W' );
359
- var queryFilteredStudySpaces = queryName.isNotEmpty
360
- ? studySpaces
357
+ var queryFilteredBuildings = queryName.isNotEmpty
358
+ ? buildings
361
359
.where ((space) =>
362
360
space.title.toLowerCase ().split (wordBoundary).any ((word) {
363
361
return queryName
@@ -368,18 +366,18 @@ class _MyHomePageState extends State<MyHomePage> {
368
366
});
369
367
}))
370
368
.toList ()
371
- : studySpaces ;
369
+ : buildings ;
372
370
final openingHoursIndex = getOpeningHoursIndex ();
373
- var filteredStudySpaces = appState
371
+ var filteredBuildings = appState
374
372
.when (
375
- filterResults: () => studySpaces
373
+ filterResults: () => buildings
376
374
.where ((space) => isOpenDuring (
377
375
OpeningHours .range (filterStartTime, filterEndTime),
378
376
space.openingHours[openingHoursIndex]))
379
377
.toList (),
380
- keywordSearch: () => queryFilteredStudySpaces ,
381
- filterSearch: () => queryFilteredStudySpaces ,
382
- home: () => queryFilteredStudySpaces ,
378
+ keywordSearch: () => queryFilteredBuildings ,
379
+ filterSearch: () => queryFilteredBuildings ,
380
+ home: () => queryFilteredBuildings ,
383
381
)
384
382
.sorted ((space1, space2) => space1.openingHours[openingHoursIndex].when (
385
383
allDay: () => space2.openingHours[openingHoursIndex].when (
@@ -406,9 +404,9 @@ class _MyHomePageState extends State<MyHomePage> {
406
404
),
407
405
body: ListView .separated (
408
406
padding: const EdgeInsets .all (8 ),
409
- itemCount: filteredStudySpaces .length,
407
+ itemCount: filteredBuildings .length,
410
408
itemBuilder: (BuildContext context, int index) {
411
- return showListItem (filteredStudySpaces [index]);
409
+ return showListItem (filteredBuildings [index]);
412
410
},
413
411
separatorBuilder: (context, index) => SizedBox (
414
412
height: Theme .of (context).textTheme.bodySmall! .fontSize! / 2 ,
@@ -630,14 +628,14 @@ class _MyHomePageState extends State<MyHomePage> {
630
628
});
631
629
}
632
630
633
- Widget showListItem (StudySpace studySpace ) {
631
+ Widget showListItem (Building building ) {
634
632
var openingHoursIndex = getOpeningHoursIndex ();
635
633
return GestureDetector (
636
634
onTap: () {
637
635
Navigator .push (
638
636
context,
639
637
MaterialPageRoute (
640
- builder: (context) => StudySpacePage (studySpace : studySpace ),
638
+ builder: (context) => BuildingPage (building : building ),
641
639
));
642
640
},
643
641
child: Card (
@@ -649,14 +647,14 @@ class _MyHomePageState extends State<MyHomePage> {
649
647
child: Column (
650
648
children: [
651
649
Text (
652
- studySpace .title,
650
+ building .title,
653
651
style: Theme .of (context).textTheme.titleLarge,
654
652
),
655
653
SizedBox (
656
654
height: Theme .of (context).textTheme.bodySmall! .fontSize! / 2 ),
657
655
Text (
658
656
openingHoursToString (
659
- studySpace .openingHours[openingHoursIndex]),
657
+ building .openingHours[openingHoursIndex]),
660
658
style: Theme .of (context).textTheme.bodyMedium),
661
659
],
662
660
mainAxisAlignment: MainAxisAlignment .start,
@@ -672,14 +670,14 @@ class _MyHomePageState extends State<MyHomePage> {
672
670
decoration: BoxDecoration (
673
671
image: DecorationImage (
674
672
fit: BoxFit .fitHeight,
675
- image: AssetImage (
676
- getImageUrl (id: studySpace .id))))))),
673
+ image:
674
+ AssetImage ( getImageUrl (id: building .id))))))),
677
675
]),
678
676
)),
679
677
);
680
678
}
681
679
682
- /// Get the [OpeningHours] of a study space with a [queryTitle] at a [queryDate] .
680
+ /// Get the [OpeningHours] of a building with a [queryTitle] at a [queryDate] .
683
681
OpeningHours ? getOpeningHours (String queryTitle, DateTime queryDate) {
684
682
// print(openingHours[queryTitle]
685
683
// ?.map((hours) => "${hours.startDate} - ${hours.endDate}"));
@@ -723,7 +721,7 @@ class _MyHomePageState extends State<MyHomePage> {
723
721
...fallAndWinter.values
724
722
];
725
723
ProcessedOpeningHours result = {};
726
- studySpaces .where ((space) => space.connectedToMLibraryApi).forEach ((space) {
724
+ buildings .where ((space) => space.connectedToMLibraryApi).forEach ((space) {
727
725
for (var hours in prioritizedHours) {
728
726
if (hours[space.title] != null ) {
729
727
result.putIfAbsent (space.title, () => []).addAll (hours[space.title]! );
@@ -743,7 +741,7 @@ class _MyHomePageState extends State<MyHomePage> {
743
741
744
742
final client = RoutingClient (uriDesign);
745
743
746
- // A Map from fieldHoursOpen.type (eg paragraph__hours_exceptions) to a Map from study space title to its opening hours
744
+ // A Map from fieldHoursOpen.type (eg paragraph__hours_exceptions) to a Map from building title to its opening hours
747
745
FieldOpeningHours fieldOpeningHours = {};
748
746
749
747
try {
@@ -757,7 +755,7 @@ class _MyHomePageState extends State<MyHomePage> {
757
755
758
756
for (var resource in response.collection) {
759
757
String title = resource.attributes["title" ]! as String ;
760
- if (studySpaces
758
+ if (buildings
761
759
.where ((space) => space.connectedToMLibraryApi)
762
760
.map ((space) => space.title)
763
761
.contains (title)) {
0 commit comments