diff --git a/lib/api/auth/oauth.dart b/lib/api/auth/oauth.dart index 0f5d8da..8b13789 100644 --- a/lib/api/auth/oauth.dart +++ b/lib/api/auth/oauth.dart @@ -1,7 +1 @@ -import 'package:http/http.dart' as http; -import 'dart:io'; -import 'package:oauth2/oauth2.dart' as oauth2; - -// Future authorize({required String userid}) { -// } diff --git a/lib/i18n/de_DE.json b/lib/i18n/de_DE.json new file mode 100644 index 0000000..7234b8b --- /dev/null +++ b/lib/i18n/de_DE.json @@ -0,0 +1,9 @@ +{ + "greeting": "hallo!", + "user-id-not-valid": "Hmm... die id sieht nicht ganz richtig aus...", + "user-id": "nutzer id", + "user-id-example": "nutzer@beispiel.de", + "authorize-in-browser": "im browser autorisieren", + "login-failed-snackbar-text": "login fehlgeschlagen!" +} + \ No newline at end of file diff --git a/lib/i18n/en_US.json b/lib/i18n/en_US.json index b3add8c..5ea0d46 100644 --- a/lib/i18n/en_US.json +++ b/lib/i18n/en_US.json @@ -3,6 +3,7 @@ "user-id-not-valid": "Sorry, this user id doesn't look quite right... ", "user-id": "user id", "user-id-example": "user@example.com", - "authorize-in-browser": "authorize in browser" + "authorize-in-browser": "authorize in browser", + "login-failed-snackbar-text": "login failed!" } \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 23fd812..ea09307 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,12 +2,31 @@ import 'package:flutter/material.dart'; import 'package:localization/localization.dart'; import 'package:slothmu/partials/main_scaffold.dart'; import 'pages/login.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; -void main() => runApp(MaterialApp( +void main() => runApp(const Slothmu()); + +class Slothmu extends StatefulWidget { + const Slothmu({Key? key}) : super(key: key); + + @override + State createState() => _SlothmuState(); +} + +class _SlothmuState extends State { + @override + Widget build(BuildContext context) { + LocalJsonLocalization.delegate.directories = ['lib/i18n']; + return MaterialApp( supportedLocales: const [ Locale("en", "US"), + Locale("de", "DE"), ], + locale: const Locale("de", "DE"), localizationsDelegates: [ + GlobalCupertinoLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalMaterialLocalizations.delegate, LocalJsonLocalization.delegate, ], initialRoute: '/login', @@ -15,4 +34,6 @@ void main() => runApp(MaterialApp( '/': (context) => const MainScaffold(), '/login': (context) => const Login(), }, - )); + ); + } +} diff --git a/lib/pages/login.dart b/lib/pages/login.dart index 83c0c9e..761a17e 100644 --- a/lib/pages/login.dart +++ b/lib/pages/login.dart @@ -60,7 +60,11 @@ class _LoginFormState extends State { ), TextButton.icon( onPressed: () { - formKey.currentState!.validate(); + bool isValid = formKey.currentState!.validate(); + if (!isValid) { + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: Text("login-failed-snackbar-text".i18n()))); + } }, icon: const Icon(Icons.login), label: Text("authorize-in-browser".i18n())) diff --git a/pubspec.lock b/pubspec.lock index 4be8afd..650a78f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -43,13 +43,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.16.0" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.2" cupertino_icons: dependency: "direct main" description: @@ -76,6 +69,11 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.1" + flutter_localizations: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" flutter_test: dependency: "direct dev" description: flutter @@ -95,6 +93,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.0.1" + intl: + dependency: transitive + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.17.0" lints: dependency: transitive description: @@ -130,13 +135,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.7.0" - oauth2: - dependency: "direct main" - description: - name: oauth2 - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" path: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 7bed065..43f05e7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -29,6 +29,8 @@ environment: dependencies: flutter: sdk: flutter + flutter_localizations: # Add this line + sdk: flutter # The following adds the Cupertino Icons font to your application. @@ -36,7 +38,6 @@ dependencies: cupertino_icons: ^1.0.2 settings_ui: ^2.0.2 http: ^0.13.4 - oauth2: ^2.0.0 localization: ^2.1.0 dev_dependencies: