Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made schedule search UI not crappy #142

Merged
merged 5 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ linter:
cascade_invocations: false # this often looks uglier

# Temporarily disabled until we are ready to document
public_member_api_docs: false
# public_member_api_docs: false
12 changes: 10 additions & 2 deletions android/app/google-services.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
"certificate_hash": "8de6f0b2cdbf4552c39a0210e58d30da7fddfac3"
}
},
{
"client_id": "267381428578-ondug0tlvefmbb9r68754p1vasu896vi.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.ramaz.student_life",
"certificate_hash": "e3d8e54917b767218be4bd3cc33b6f754e57d52a"
}
},
{
"client_id": "267381428578-s9bsc6bqvfebqimv3th6cjp7qildrpsc.apps.googleusercontent.com",
"client_type": 3
Expand All @@ -40,10 +48,10 @@
"client_type": 3
},
{
"client_id": "267381428578-cpk8lv86lc3dcq62iegfc98dr3c0tt3u.apps.googleusercontent.com",
"client_id": "267381428578-7a8kkf45mdkepv1vr4j39gmlclcgob1u.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "com.example.authTest"
"bundle_id": "com.ramaz.ramaz.student-life"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ subprojects {
}
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
7 changes: 7 additions & 0 deletions ios/firebase_app_id_file.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"file_generated_by": "FlutterFire CLI",
"purpose": "FirebaseAppID & ProjectID for this Firebase app in this directory",
"GOOGLE_APP_ID": "1:267381428578:ios:196e12b81f2bcae22c5c3b",
"FIREBASE_PROJECT_ID": "ramaz-go",
"GCM_SENDER_ID": "267381428578"
}
21 changes: 15 additions & 6 deletions lib/firebase_options.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// File generated by FlutterFire CLI.
// ignore_for_file: lines_longer_than_80_chars
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart'
show defaultTargetPlatform, kIsWeb, TargetPlatform;
Expand All @@ -19,7 +19,6 @@ class DefaultFirebaseOptions {
if (kIsWeb) {
return web;
}
// ignore: missing_enum_constant_in_switch
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return android;
Expand All @@ -30,11 +29,21 @@ class DefaultFirebaseOptions {
'DefaultFirebaseOptions have not been configured for macos - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.windows:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for windows - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.linux:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for linux - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
default:
throw UnsupportedError(
'DefaultFirebaseOptions are not supported for this platform.',
);
}

throw UnsupportedError(
'DefaultFirebaseOptions are not supported for this platform.',
);
}

static const FirebaseOptions web = FirebaseOptions(
Expand Down
1 change: 1 addition & 0 deletions lib/src/data/types.dart
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/// An alias for a JSON map.
typedef Json = Map<String, dynamic>;
78 changes: 36 additions & 42 deletions lib/src/pages/schedule.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import "package:flutter/material.dart";

import "package:link_text/link_text.dart";
import "package:url_launcher/url_launcher_string.dart";

import "package:ramaz/data.dart";
import "package:ramaz/models.dart";
Expand All @@ -9,7 +8,7 @@ import "package:ramaz/widgets.dart";
import "drawer.dart";

/// Allows users to explore their schedule.
///
///
/// Users can use the calendar button to check the schedule for a given date
/// or create a custom [Day] from the drop-down menus.
class SchedulePage extends StatelessWidget {
Expand Down Expand Up @@ -37,10 +36,10 @@ class SchedulePage extends StatelessWidget {
}
}

/// Lets the user know that they chose an invalid schedule combination.
void handleInvalidSchedule(BuildContext context) => ScaffoldMessenger
.of(context)
.showSnackBar(const SnackBar(content: Text("Invalid schedule")));
/// Lets the user know that they chose an invalid schedule combination.
void handleInvalidSchedule(BuildContext context) =>
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text("Invalid schedule")));

@override
Widget build(BuildContext context) => ProviderConsumer(
Expand Down Expand Up @@ -119,24 +118,23 @@ class CustomSearchDelegate extends SearchDelegate<Subject> {
/// This model handles the searching logic.
final ScheduleSearchModel model = ScheduleSearchModel();

/// A constructor that constructs the search bar.
CustomSearchDelegate({
required String hintText,
}) : super(
searchFieldLabel: hintText,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.search,
);
/// A constructor that constructs the search bar.
CustomSearchDelegate({
required String hintText,
}) : super(
searchFieldLabel: hintText,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.search,
);

@override
Widget buildLeading(BuildContext context) => ElevatedButton(
onPressed: () => Navigator.of(context).pop(),
child: const Icon(Icons.arrow_back),
);

@override
Widget buildSuggestions(BuildContext context) {

@override
Widget buildSuggestions(BuildContext context) {
final subjects = model.getMatchingClasses(query.toLowerCase());

return ListView(
Expand All @@ -162,9 +160,8 @@ class CustomSearchDelegate extends SearchDelegate<Subject> {
);
}

@override
Widget buildResults(BuildContext context) {

@override
Widget buildResults(BuildContext context) {
final subjects = model.getMatchingClasses(query.toLowerCase());

return ListView(
Expand Down Expand Up @@ -199,12 +196,11 @@ class CustomSearchDelegate extends SearchDelegate<Subject> {

/// A class that creates each individual suggestion.
class SuggestionWidget extends StatelessWidget {
/// The function to be run when the suggestion is clicked.
final VoidCallback onTap;

/// The function to be run when the suggestion is clicked.
final VoidCallback onTap;

/// The Subject given to the widget.
final Subject suggestion;
/// The Subject given to the widget.
final Subject suggestion;

/// A constructor that defines what a suggestion should have.
const SuggestionWidget({
Expand All @@ -226,19 +222,18 @@ class SuggestionWidget extends StatelessWidget {
children: [
Text(
suggestion.name,
style: Theme.of(context).textTheme.headlineMedium,
style: Theme.of(context).textTheme.titleMedium,
),
const SizedBox(height: 5),
Text(
"${suggestion.teacher} ${suggestion.id}",
style: Theme.of(context).textTheme.titleLarge,
style: Theme.of(context).textTheme.bodySmall,
),
const SizedBox(height: 10),
if (suggestion.virtualLink != null)
LinkText(
"Link: ${suggestion.virtualLink}",
shouldTrimParams: true,
linkStyle: const TextStyle(color: Colors.blue),
TextButton(
child: Text(suggestion.virtualLink!),
onPressed: () => launchUrlString(suggestion.virtualLink!),
),
],
),
Expand All @@ -257,28 +252,27 @@ class SuggestionWidget extends StatelessWidget {

/// A class that creates each individual result.
class ResultWidget extends StatelessWidget {
/// The PeriodData given to the widget.
final PeriodData period;

/// The PeriodData given to the widget.
final PeriodData period;

/// A constructor that defines what a result should have.
const ResultWidget(this.period);
/// A constructor that defines what a result should have.
const ResultWidget(this.period);

@override
Widget build(BuildContext context) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ListTile(
title: Text(
period.dayName,
style: Theme.of(context).textTheme.headlineMedium,
"${period.dayName} Period ${period.name}",
style: Theme.of(context).textTheme.titleMedium,
),
subtitle: Text(
"Period ${period.name} Room ${period.room}",
style: Theme.of(context).textTheme.titleLarge,
"Room ${period.room}",
style: Theme.of(context).textTheme.bodySmall,
),
),
for (final int reminder in Models.instance.reminders.getReminders(
for (final reminder in Models.instance.reminders.getReminders(
dayName: period.dayName,
period: period.name,
subject: Models.instance.user.subjects[period.id]?.name,
Expand Down
6 changes: 3 additions & 3 deletions lib/src/services/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ class Auth {
///
/// Returns null if the user is not an admin (ie, [isAdmin] returns false).
static Future<List<String>?> get adminScopes async {
final Iterable<String>? customClaims = (await claims)?["scopes"];
final Iterable<dynamic>? customClaims = (await claims)?["scopes"];
return customClaims == null ? null : [
for (final String scope in customClaims)
scope,
for (final scope in customClaims)
scope as String,
];
}

Expand Down
7 changes: 1 addition & 6 deletions lib/src/widgets/atomic/info_card.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "package:flutter/material.dart";
import "package:link_text/link_text.dart";

/// A tile to represent some info.
///
Expand Down Expand Up @@ -45,11 +44,7 @@ class InfoCard extends StatelessWidget {
...[
for (final String text in children!) ...[
const SizedBox(height: 2.5),
LinkText(
text,
shouldTrimParams: true,
linkStyle: const TextStyle(color: Color(0xff0000EE)),
),
Text(text),
const SizedBox(height: 2.5),
],
],
Expand Down
7 changes: 1 addition & 6 deletions lib/src/widgets/generic/class_list.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "package:flutter/material.dart";
import "package:link_text/link_text.dart";

import "package:ramaz/data.dart";
import "package:ramaz/models.dart";
Expand Down Expand Up @@ -59,11 +58,7 @@ class ClassPanel extends StatelessWidget {
for (final String label in children)
Padding (
padding: const EdgeInsets.symmetric(vertical: 5),
child: LinkText(
label,
shouldTrimParams: true,
linkStyle: const TextStyle(color: Color(0xff0000EE)),
),
child: Text(label),
),
if (activity != null)
ActivityTile(activity!), // already checked for null
Expand Down
8 changes: 0 additions & 8 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.6.7"
link_text:
dependency: "direct main"
description:
name: link_text
sha256: "5babfe3bcd987bb3f1dde61a47aa55ffd05137634a392385c899651e788d7ebc"
url: "https://pub.dev"
source: hosted
version: "0.2.0"
matcher:
dependency: "direct dev"
description:
Expand Down
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ dependencies:
# flutter_native_timezone: ^2.0.0
url_launcher: ^6.0.3
adaptive_breakpoints: ^0.1.6
link_text: ^0.2.0
provider: ^6.0.5
meta: ^1.9.1
timezone: ^0.9.2
Expand Down
Loading