mirror of
https://github.com/go-vikunja/app
synced 2024-06-02 18:49:47 +00:00
removed popup on failed login
added send test notification to settings
This commit is contained in:
parent
d0dcb4452d
commit
adc22078eb
|
@ -11,13 +11,15 @@ class UserAPIService extends APIService implements UserService {
|
|||
UserAPIService(Client client) : super(client);
|
||||
|
||||
@override
|
||||
Future<UserTokenPair> login(String username, password, {bool rememberMe = false, String? totp}) async {
|
||||
Future<UserTokenPair?> login(String username, password, {bool rememberMe = false, String? totp}) async {
|
||||
var token = await client.post('/login', body: {
|
||||
'long_token': rememberMe,
|
||||
'password': password,
|
||||
'totp_passcode': totp,
|
||||
'username': username,
|
||||
}).then((response) => response?.body['token']);
|
||||
if(token == null)
|
||||
return Future.value(null);
|
||||
client.configure(token: token);
|
||||
return UserAPIService(client)
|
||||
.getCurrentUser()
|
||||
|
@ -25,7 +27,7 @@ class UserAPIService extends APIService implements UserService {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<UserTokenPair> register(String username, email, password) async {
|
||||
Future<UserTokenPair?> register(String username, email, password) async {
|
||||
var newUser = await client.post('/register', body: {
|
||||
'username': username,
|
||||
'email': email,
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
// https://medium.com/@fuzzymemory/adding-scheduled-notifications-in-your-flutter-application-19be1f82ade8
|
||||
|
||||
import 'dart:math';
|
||||
import 'dart:developer' as dev;
|
||||
|
||||
|
||||
import 'package:flutter_native_timezone/flutter_native_timezone.dart';
|
||||
import 'package:timezone/data/latest_all.dart' as tz;
|
||||
import 'package:timezone/timezone.dart' as tz;
|
||||
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart'as notifs;
|
||||
import 'package:rxdart/subjects.dart' as rxSub;
|
||||
import 'package:vikunja_app/global.dart';
|
||||
|
||||
class NotificationClass{
|
||||
final int? id;
|
||||
|
@ -26,7 +21,7 @@ class NotificationClass{
|
|||
|
||||
Future<void> initNotifications(notifs.FlutterLocalNotificationsPlugin notifsPlugin) async {
|
||||
var initializationSettingsAndroid =
|
||||
notifs.AndroidInitializationSettings('ic_launcher_foreground');
|
||||
notifs.AndroidInitializationSettings('vikunja_logo');
|
||||
var initializationSettingsIOS = notifs.IOSInitializationSettings(
|
||||
requestAlertPermission: false,
|
||||
requestBadgePermission: false,
|
||||
|
@ -62,6 +57,11 @@ Future<void> scheduleNotification(String title, String description,
|
|||
time, platformChannelSpecifics, androidAllowWhileIdle: true, uiLocalNotificationDateInterpretation: notifs.UILocalNotificationDateInterpretation.wallClockTime); // This literally schedules the notification
|
||||
}
|
||||
|
||||
void sendTestNotification(notifs.FlutterLocalNotificationsPlugin notifsPlugin, notifs.NotificationDetails platformChannelSpecifics) {
|
||||
notifsPlugin.show(Random().nextInt(10000000), "Test Notification", "This is a test notification", platformChannelSpecifics);
|
||||
}
|
||||
|
||||
|
||||
void requestIOSPermissions(
|
||||
notifs.FlutterLocalNotificationsPlugin notifsPlugin) {
|
||||
notifsPlugin.resolvePlatformSpecificImplementation<notifs.IOSFlutterLocalNotificationsPlugin>()
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:vikunja_app/global.dart';
|
||||
import 'package:vikunja_app/models/list.dart';
|
||||
import 'package:vikunja_app/managers/notifications.dart';
|
||||
|
||||
class SettingsPage extends StatefulWidget {
|
||||
@override
|
||||
|
@ -95,6 +96,10 @@ class SettingsPageState extends State<SettingsPage> {
|
|||
VikunjaGlobal.of(context).settingsManager.setVersionNotifications(value);
|
||||
})
|
||||
: ListTile(title: Text("...")),
|
||||
TextButton(onPressed: () {
|
||||
sendTestNotification(VikunjaGlobal.of(context).notificationsPlugin
|
||||
, VikunjaGlobal.of(context).platformChannelSpecificsReminders);
|
||||
}, child: Text("Send test notification")),
|
||||
TextButton(
|
||||
onPressed: () => VikunjaGlobal.of(context)
|
||||
.versionChecker
|
||||
|
@ -103,7 +108,7 @@ class SettingsPageState extends State<SettingsPage> {
|
|||
child: Text("Check for latest version")),
|
||||
Text("Current version: ${versionTag ?? "loading"}"),
|
||||
Text(newestVersionTag != null
|
||||
? "Newest version: $newestVersionTag"
|
||||
? "Latest version: $newestVersionTag"
|
||||
: "")
|
||||
],
|
||||
),
|
||||
|
|
|
@ -222,7 +222,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||
if(newUser != null)
|
||||
vGlobal.changeUser(newUser.user, token: newUser.token, base: _server);
|
||||
} catch (ex, stacktrace) {
|
||||
log(stacktrace.toString());
|
||||
/* log(stacktrace.toString());
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => new AlertDialog(
|
||||
|
@ -235,6 +235,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||
child: const Text('Close'))
|
||||
],
|
||||
));
|
||||
*/
|
||||
} finally {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
|
|
Loading…
Reference in New Issue
Block a user