Skip to content

Commit

Permalink
Add Room Search to Quick Actions (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobkoerber authored Nov 14, 2024
1 parent 883c51e commit e223ab7
Show file tree
Hide file tree
Showing 61 changed files with 651 additions and 727 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ android {
applicationId "de.tum.in.tumcampus"
minSdkVersion 29
targetSdkVersion flutter.targetSdkVersion
ndkVersion "26.1.10909125"
ndkVersion "27.0.12077973"
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version '8.6.1' apply false
id "com.android.application" version '8.7.0' apply false
id "org.jetbrains.kotlin.android" version "1.9.20" apply false
id "org.jetbrains.kotlin.plugin.serialization" version "2.0.21" apply false
id "com.google.gms.google-services" version "4.4.2" apply false
Expand Down
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_native_splash: edf599c81f74d093a4daf8e17bd7a018854bc778
flutter_secure_storage: d33dac7ae2ea08509be337e775f6b59f1ff45f12
geolocator_apple: 6cbaf322953988e009e5ecb481f07efece75c450
geolocator_apple: 9bcea1918ff7f0062d98345d238ae12718acfbc1
Google-Maps-iOS-Utils: 66d6de12be1ce6d3742a54661e7a79cb317a9321
google_maps_flutter_ios: e31555a04d1986ab130f2b9f24b6cdc861acc6d3
GoogleDataTransport: aae35b7ea0c09004c3797d53c8c41f66f219d6a7
Expand Down
40 changes: 40 additions & 0 deletions lib/base/enums/search_category.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
import 'package:campus_flutter/searchComponent/protocols/search_category_viewmodel.dart';
import 'package:campus_flutter/searchComponent/viewModels/searchableViewModels/cafeteria_search_viewmodel.dart';
import 'package:campus_flutter/searchComponent/viewModels/searchableViewModels/calendar_search_viewmodel.dart';
import 'package:campus_flutter/searchComponent/viewModels/searchableViewModels/grades_search_viewmodel.dart';
import 'package:campus_flutter/searchComponent/viewModels/searchableViewModels/lecture_search_viewmodel.dart';
import 'package:campus_flutter/searchComponent/viewModels/searchableViewModels/movie_search_viewmodel.dart';
import 'package:campus_flutter/searchComponent/viewModels/searchableViewModels/navigatum_search_viewmodel.dart';
import 'package:campus_flutter/searchComponent/viewModels/searchableViewModels/news_search_viewmodel.dart';
import 'package:campus_flutter/searchComponent/viewModels/searchableViewModels/person_search_viewmodel.dart';
import 'package:campus_flutter/searchComponent/viewModels/searchableViewModels/personal_lecture_seach_viewmodel.dart';
import 'package:campus_flutter/searchComponent/viewModels/searchableViewModels/student_club_search_viewmodel.dart';
import 'package:campus_flutter/searchComponent/viewModels/searchableViewModels/study_room_search_viewmodel.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

enum SearchCategory {
cafeterias,
Expand Down Expand Up @@ -62,4 +75,31 @@ extension SearchCategoryExtension on SearchCategory {
SearchCategory.studentClub,
];
}

Provider<SearchCategoryViewModel> get viewModel {
switch (this) {
case SearchCategory.cafeterias:
return cafeteriaSearchViewModel;
case SearchCategory.calendar:
return calendarSearchViewModel;
case SearchCategory.grade:
return gradesSearchViewModel;
case SearchCategory.movie:
return movieSearchViewModel;
case SearchCategory.news:
return newsSearchViewModel;
case SearchCategory.studyRoom:
return studyRoomSearchViewModel;
case SearchCategory.lectures:
return lectureSearchViewModel;
case SearchCategory.personalLectures:
return personalLectureSearchViewModel;
case SearchCategory.persons:
return personSearchViewModel;
case SearchCategory.rooms:
return navigaTumSearchViewModel;
case SearchCategory.studentClub:
return studentClubSearchViewModel;
}
}
}
5 changes: 5 additions & 0 deletions lib/base/enums/search_type.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
enum SearchType {
general,
room,
person;
}
18 changes: 6 additions & 12 deletions lib/base/enums/shortcut_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ enum ShortcutItemType {
cafeterias(en: "Cafeterias", de: "Mensen"),
studyRooms(en: "Study Rooms", de: "Lernräume"),
calendar(en: "Calendar", de: "Kalendar"),
studies(en: "Studies", de: "Studium");
studies(en: "Studies", de: "Studium"),
roomSearch(en: "Room Search", de: "Raumsuche");

final String en;
final String? de;
Expand All @@ -24,16 +25,7 @@ extension Routing on ShortcutItemType {
return isGerman ? de! : en;
}

String? get icon {
switch (this) {
case ShortcutItemType.home:
case ShortcutItemType.cafeterias:
case ShortcutItemType.studyRooms:
case ShortcutItemType.calendar:
case ShortcutItemType.studies:
return null;
}
}
String? get icon => null;

ShortcutItem shortcutItem(Locale? locale) {
return ShortcutItem(
Expand All @@ -55,14 +47,16 @@ extension Routing on ShortcutItemType {
return routes.calendar;
case ShortcutItemType.studies:
return routes.studies;
case ShortcutItemType.roomSearch:
return routes.roomSearch;
}
}
}

extension ActiveShortcuts on ShortcutItemType {
static List<ShortcutItemType> get items => [
ShortcutItemType.cafeterias,
ShortcutItemType.studyRooms,
ShortcutItemType.roomSearch,
ShortcutItemType.calendar,
ShortcutItemType.studies,
];
Expand Down
34 changes: 21 additions & 13 deletions lib/base/routing/router.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:campus_flutter/base/enums/campus.dart';
import 'package:campus_flutter/base/enums/search_type.dart';
import 'package:campus_flutter/base/util/fullscreen_image_view.dart';
import 'package:campus_flutter/base/routing/router_service.dart';
import 'package:campus_flutter/base/routing/routes.dart';
Expand Down Expand Up @@ -31,8 +32,8 @@ import 'package:campus_flutter/placesComponent/views/campuses/campus_scaffold.da
import 'package:campus_flutter/placesComponent/views/places_screen.dart';
import 'package:campus_flutter/placesComponent/views/studyGroups/study_room_group_scaffold.dart';
import 'package:campus_flutter/placesComponent/views/studyGroups/study_rooms_view.dart';
import 'package:campus_flutter/searchComponent/views/appWideSearch/search_scaffold.dart';
import 'package:campus_flutter/searchComponent/views/personRoomSearch/search_view.dart';
import 'package:campus_flutter/searchComponent/viewModels/search_viewmodel.dart';
import 'package:campus_flutter/searchComponent/views/search_scaffold.dart';
import 'package:campus_flutter/settingsComponent/views/settings_scaffold.dart';
import 'package:campus_flutter/studiesComponent/model/lecture.dart';
import 'package:campus_flutter/studiesComponent/screen/studies_screen.dart';
Expand Down Expand Up @@ -220,7 +221,24 @@ final _router = GoRouter(
),
GoRoute(
path: search,
builder: (context, state) => const SearchScaffold(),
builder: (context, state) => SearchScaffold(
searchVM: searchViewModel(SearchType.general),
searchString: state.extra as String?,
),
),
GoRoute(
path: roomSearch,
builder: (context, state) => SearchScaffold(
searchVM: searchViewModel(SearchType.room),
searchString: state.extra as String?,
),
),
GoRoute(
path: personSearch,
builder: (context, state) => SearchScaffold(
searchVM: searchViewModel(SearchType.person),
searchString: state.extra as String?,
),
),
GoRoute(
path: studyRoom,
Expand All @@ -244,16 +262,6 @@ final _router = GoRouter(
imageData: state.extra as String,
),
),
GoRoute(
path: roomSearch,
builder: (context, state) {
final data = state.extra as (String?, bool?);
return PersonRoomSearchScaffold(
searchString: data.$1,
isRoomSearch: data.$2 ?? true,
);
},
),
GoRoute(
path: eventCreation,
builder: (context, state) => EventCreationScaffold(
Expand Down
7 changes: 5 additions & 2 deletions lib/base/routing/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ const menuSettings = "/menu+settings";
const feedback = "$menuSettings/feedback";
const feedbackSuccess = "$feedback/success";

/// General
/// Search
const search = "/search";
const roomSearch = "/roomSearch";
const personSearch = "/personSearch";

/// General
const navigaTum = "/navigaTum";
const personDetails = "/personDetails";
const cafeteria = "/cafeteria";
const studyRoom = "/studyRoom";
const networkImage = "/networkImage";
const localeImage = "/localeImage";
const roomSearch = "/roomSearch";
14 changes: 13 additions & 1 deletion lib/base/util/custom_back_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,30 @@ import 'package:go_router/go_router.dart';
class CustomBackButton extends StatelessWidget {
const CustomBackButton({
super.key,
this.beforeOnPressed,
this.onPressed,
this.color,
});

final Function()? onPressed;
final Function()? beforeOnPressed;
final Color? color;

@override
Widget build(BuildContext context) {
return BackButton(
color: color,
onPressed: onPressed ?? () => defaultOnPressed(context),
onPressed: () {
if (beforeOnPressed != null) {
beforeOnPressed!();
}

if (onPressed != null) {
onPressed!();
} else {
defaultOnPressed(context);
}
},
);
}

Expand Down
7 changes: 7 additions & 0 deletions lib/base/util/speaker.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Speaker {
static String getSpeakerName(String speakerString) {
final speakers = speakerString.split(", ");
final mainSpeaker = speakers.first.split(" [L]");
return mainSpeaker.first.split(" (").first;
}
}
7 changes: 1 addition & 6 deletions lib/calendarComponent/views/calendars_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class CalendarsView extends ConsumerStatefulWidget {
ConsumerState<ConsumerStatefulWidget> createState() => _CalendarsViewState();
}

class _CalendarsViewState extends ConsumerState<CalendarsView>
with AutomaticKeepAliveClientMixin<CalendarsView> {
class _CalendarsViewState extends ConsumerState<CalendarsView> {
late int _selectedCalendarTab;

final CalendarController dayController = CalendarController();
Expand All @@ -47,7 +46,6 @@ class _CalendarsViewState extends ConsumerState<CalendarsView>

@override
Widget build(BuildContext context) {
super.build(context);
return StreamBuilder(
stream: ref.watch(calendarViewModel).events,
builder: (context, snapshot) {
Expand Down Expand Up @@ -141,9 +139,6 @@ class _CalendarsViewState extends ConsumerState<CalendarsView>
);
}

@override
bool get wantKeepAlive => true;

void _selectedDateListener((DateTime?, CalendarView?) state) {
switch (state.$2) {
case CalendarView.day:
Expand Down
7 changes: 1 addition & 6 deletions lib/homeComponent/screen/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ class HomeScreen extends ConsumerStatefulWidget {
ConsumerState<ConsumerStatefulWidget> createState() => _HomeScreenState();
}

class _HomeScreenState extends ConsumerState<HomeScreen>
with AutomaticKeepAliveClientMixin {
class _HomeScreenState extends ConsumerState<HomeScreen> {
final ScrollController scrollController = ScrollController();

@override
Widget build(BuildContext context) {
super.build(context);
return OrientationBuilder(
builder: (context, orientation) {
if (orientation == Orientation.portrait) {
Expand All @@ -43,7 +41,4 @@ class _HomeScreenState extends ConsumerState<HomeScreen>
),
);
}

@override
bool get wantKeepAlive => true;
}
7 changes: 1 addition & 6 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ class CampusApp extends ConsumerStatefulWidget {
ConsumerState<ConsumerStatefulWidget> createState() => _CampusAppState();
}

class _CampusAppState extends ConsumerState<CampusApp>
with AutomaticKeepAliveClientMixin {
class _CampusAppState extends ConsumerState<CampusApp> {
late QuickActions quickActions;

@override
Expand All @@ -146,7 +145,6 @@ class _CampusAppState extends ConsumerState<CampusApp>

@override
Widget build(BuildContext context) {
super.build(context);
return MaterialApp.router(
title: "TUM Campus App",
debugShowCheckedModeBanner: false,
Expand Down Expand Up @@ -235,7 +233,4 @@ class _CampusAppState extends ConsumerState<CampusApp>
}
});
}

@override
bool get wantKeepAlive => true;
}
7 changes: 5 additions & 2 deletions lib/navigation_service.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import 'dart:io';

import 'package:campus_flutter/base/enums/credentials.dart';
import 'package:campus_flutter/base/enums/search_type.dart';
import 'package:campus_flutter/base/routing/routes.dart';
import 'package:campus_flutter/homeComponent/view/widget/widget_screen.dart';
import 'package:campus_flutter/main.dart';
import 'package:campus_flutter/onboardingComponent/viewModels/onboarding_viewmodel.dart';
import 'package:campus_flutter/searchComponent/viewModels/global_search_viewmodel.dart';
import 'package:campus_flutter/searchComponent/viewModels/search_viewmodel.dart';
import 'package:campus_flutter/studentCardComponent/views/student_card_view.dart';
import 'package:campus_flutter/base/extensions/context.dart';
import 'package:easy_localization/easy_localization.dart';
Expand Down Expand Up @@ -81,7 +82,9 @@ class NavigationService {
Widget searchButton(int currentIndex, WidgetRef ref, BuildContext context) {
return IconButton(
onPressed: () {
ref.read(searchViewModel).setSearchCategories(currentIndex);
ref
.read(searchViewModel(SearchType.general))
.setSearchCategories(currentIndex);
context.push(search);
},
icon: const Icon(Icons.search),
Expand Down
2 changes: 1 addition & 1 deletion lib/placesComponent/model/studyRooms/study_room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class StudyRoom extends Searchable {
}

bool get isAvailable {
return status == "frei" || (percent != null && percent! < 100);
return status == "frei" || (percent != null && percent! < 1);
}

@override
Expand Down
7 changes: 1 addition & 6 deletions lib/placesComponent/views/places_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ class PlacesScreen extends ConsumerStatefulWidget {
ConsumerState<ConsumerStatefulWidget> createState() => _PlacesScreenState();
}

class _PlacesScreenState extends ConsumerState<PlacesScreen>
with AutomaticKeepAliveClientMixin<PlacesScreen> {
class _PlacesScreenState extends ConsumerState<PlacesScreen> {
@override
void initState() {
ref.read(placesViewModel).fetch(false);
Expand All @@ -26,7 +25,6 @@ class _PlacesScreenState extends ConsumerState<PlacesScreen>

@override
Widget build(BuildContext context) {
super.build(context);
return FutureBuilder(
future: Future.wait([
ref.watch(studyRoomsViewModel).fetch(false),
Expand All @@ -50,7 +48,4 @@ class _PlacesScreenState extends ConsumerState<PlacesScreen>
},
);
}

@override
bool get wantKeepAlive => true;
}
Loading

0 comments on commit e223ab7

Please sign in to comment.