21 lines
687 B
Dart
21 lines
687 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:seshat/data/repositories/auth_repository.dart';
|
|
import 'package:seshat/utils/command.dart';
|
|
import 'package:seshat/utils/result.dart';
|
|
|
|
class LoginViewModel extends ChangeNotifier {
|
|
LoginViewModel({required AuthRepository authRepository})
|
|
: _authRepository = authRepository {
|
|
login = Command1<void, (String username, String password)>(_login);
|
|
}
|
|
|
|
final AuthRepository _authRepository;
|
|
|
|
late Command1 login;
|
|
|
|
Future<Result<void>> _login((String, String) credentials) async {
|
|
final (username, password) = credentials;
|
|
final result = await _authRepository.login(username, password);
|
|
return result;
|
|
}
|
|
}
|