Skip to content

Commit

Permalink
error screen
Browse files Browse the repository at this point in the history
  • Loading branch information
lkwslr committed Oct 13, 2024
1 parent 346a882 commit 70c9fe2
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 27 deletions.
6 changes: 3 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ android {

compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '17'
}

sourceSets {
Expand Down
3 changes: 3 additions & 0 deletions lib/helper/networking/timetable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class TimeTable {
await downloadLerngruppen();
await downloadStundenplan();
} else {
await StorageProvider.isar.writeTxn(() async {
await StorageProvider.isar.schulstundes.filter().syncedEqualTo(true).deleteAll();
});
//TODO: deprecated?
Isar isar = StorageProvider.isar;
List<List> availableLesson = [];
Expand Down
105 changes: 83 additions & 22 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,61 @@ Future<void> main() async {
value: StorageNotifier(), child: const SPHPlaner()));
}

class CustomError extends StatelessWidget {
final FlutterErrorDetails errorDetails;

const CustomError({
super.key,
required this.errorDetails,
});

@override
Widget build(BuildContext context) {
return Card(
margin: EdgeInsets.zero,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: ListView(
children: [
Text(
"Es ist ein Fehler aufgetreten",
textAlign: TextAlign.center,
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
Text(
"Um dabei zu helfen diese App besser zu machen, würde ich mich freuen, "
"wenn du mir die Fehlermeldung per E-Mail (sphplaner@lkwslr.de) oder über ein Github-Issue zu kommen lässt. Danke!",
),
ElevatedButton(
onPressed: () {
Clipboard.setData(
ClipboardData(text: errorDetails.toString()));
},
style: ElevatedButton.styleFrom(
minimumSize: Size.fromHeight(32),
backgroundColor: Theme.of(context).colorScheme.primary,
),
child: Text(
"Fehlermeldung kopieren",
style:
TextStyle(color: Theme.of(context).colorScheme.onPrimary),
)),
Text(
errorDetails.toString(),
style: const TextStyle(
fontWeight: FontWeight.w200,
fontStyle: FontStyle.italic
),
)
],
),
),
);
}
}

class SPHPlaner extends StatefulWidget {
const SPHPlaner({super.key});

Expand Down Expand Up @@ -167,9 +222,6 @@ class _SPHPlaner extends State<SPHPlaner> {
darkColorScheme = defaultDarkColorScheme;
}

lightColorScheme = defaultLightColorScheme;
darkColorScheme = defaultDarkColorScheme;

InputDecorationTheme customLightInputTheme = InputDecorationTheme(
enabledBorder: OutlineInputBorder(
borderSide:
Expand Down Expand Up @@ -220,6 +272,15 @@ class _SPHPlaner extends State<SPHPlaner> {
inputDecorationTheme: customDarkInputTheme,
),
themeMode: StorageProvider.theme,
builder: (context, widget) {
ErrorWidget.builder = (FlutterErrorDetails errorDetails) {
return CustomError(errorDetails: errorDetails);
};
return widget ??
Center(
child: CircularProgressIndicator(),
);
},
home: PropertyChangeConsumer<StorageNotifier, String>(
properties: const ['main'],
builder: (context, notify, child) {
Expand Down Expand Up @@ -276,7 +337,7 @@ class _SPHPlaner extends State<SPHPlaner> {
"stundenplan";
break;
}
/*TODO case 2:
/*TODO case 2:
{
StorageProvider.settings.viewMode =
"hausaufgaben";
Expand All @@ -285,13 +346,13 @@ class _SPHPlaner extends State<SPHPlaner> {
case 2: //3, wenn hausaufgaben vorhanden
{
StorageProvider.settings.viewMode =
"lerngruppen";
"lerngruppen";
break;
}
case 3: //4, wenn hausaufgaben vorhanden
{
StorageProvider.settings.viewMode =
"kalender";
"kalender";
break;
}
}
Expand Down Expand Up @@ -387,22 +448,22 @@ class _SPHPlaner extends State<SPHPlaner> {
List<Widget>? buildActions(String view, BuildContext context) {
List<Widget> actions = [
if (StorageProvider.settings.updateLock)
Padding(
padding: const EdgeInsets.only(right: 10, left: 10),
child: PropertyChangeConsumer<StorageNotifier, String>(
properties: const ['updateLock'],
builder: (context, notify, child) {
return Center(
child: SizedBox(
width: 16,
height: 16,
child: CircularProgressIndicator(
strokeWidth: 3,
color: Theme.of(context).textTheme.bodyMedium?.color,
),
));
},
)),
Padding(
padding: const EdgeInsets.only(right: 10, left: 10),
child: PropertyChangeConsumer<StorageNotifier, String>(
properties: const ['updateLock'],
builder: (context, notify, child) {
return Center(
child: SizedBox(
width: 16,
height: 16,
child: CircularProgressIndicator(
strokeWidth: 3,
color: Theme.of(context).textTheme.bodyMedium?.color,
),
));
},
)),
Padding(
padding: const EdgeInsets.only(right: 10, left: 10),
child: GestureDetector(
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/stundenplan.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class _StundenplanState extends State<Stundenplan> {

Schulstunde? lesson = StorageProvider.isar.schulstundes
.where()
.wochentagStundeEqualTo(day - 1, hour)
.wochentagStundeEqualTo(day - 1 + (StorageProvider.settings.lerngruppen ? 0 : 1), hour)
.findFirstSync();

Vertretung? vertretung = StorageProvider.isar.vertretungs
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 2.7.0+20700
version: 2.7.1-beta+20701-beta

environment:
sdk: ">=2.17.0-0 <3.0.0"
Expand Down

0 comments on commit 70c9fe2

Please sign in to comment.