Improve repo structure (#22)
* app updated * readme updated * rename base folder * update chatty's readme * move apps to packages dir * update repo overview Co-authored-by: diegoveloper <[email protected]>
This commit is contained in:
co-authored by
diegoveloper
parent
bd6bb66279
commit
030c3eb428
@@ -0,0 +1,44 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:stream_chatter/data/image_picker_repository.dart';
|
||||
import 'package:stream_chatter/domain/usecases/profile_sign_in_usecase.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class ProfileState {
|
||||
const ProfileState(
|
||||
this.file, {
|
||||
this.success = false,
|
||||
this.loading = false,
|
||||
});
|
||||
final File file;
|
||||
final bool success;
|
||||
final bool loading;
|
||||
}
|
||||
|
||||
class ProfileVerifyCubit extends Cubit<ProfileState> {
|
||||
ProfileVerifyCubit(
|
||||
this._imagePickerRepository,
|
||||
this._profileSignInUseCase,
|
||||
) : super(ProfileState(null));
|
||||
|
||||
final nameController = TextEditingController();
|
||||
final ImagePickerRepository _imagePickerRepository;
|
||||
final ProfileSignInUseCase _profileSignInUseCase;
|
||||
|
||||
void startChatting() async {
|
||||
emit(ProfileState(null, loading: true));
|
||||
final file = state.file;
|
||||
final name = nameController.text;
|
||||
await _profileSignInUseCase.verify(ProfileInput(
|
||||
imageFile: file,
|
||||
name: name,
|
||||
));
|
||||
emit(ProfileState(file, success: true, loading: false));
|
||||
}
|
||||
|
||||
void pickImage() async {
|
||||
final file = await _imagePickerRepository.pickImage();
|
||||
emit(ProfileState(file));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user