aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/screens/login/login_screen_presenter.dart
blob: fc5da4f831e3aff9e61e0a0f27a82093b776ba5c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import 'package:beam_messenger/data/rest_ds.dart';
import 'package:beam_messenger/models/user.dart';

abstract class LoginScreenContract {
  void onLoginSuccess(User user);
  void onLoginError(String errorTxt);
}

class LoginScreenPresenter {
  LoginScreenContract _view;
  RestDatasource api = new RestDatasource();
  LoginScreenPresenter(this._view);

  doLogin(String email, String password) {
    api.login(email, password).then((User user) {
      _view.onLoginSuccess(user);
    }).catchError((Exception error) => _view.onLoginError(error.toString()));
  }
}