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));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
import 'package:stream_chatter/navigator_utils.dart';
|
||||
import 'package:stream_chatter/ui/common/avatar_image_view.dart';
|
||||
import 'package:stream_chatter/ui/common/loading_view.dart';
|
||||
import 'package:stream_chatter/ui/home/home_view.dart';
|
||||
import 'package:stream_chatter/ui/profile_verify/profile_verify_cubit.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class ProfileVerifyView extends StatelessWidget {
|
||||
ProfileVerifyView();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => ProfileVerifyCubit(context.read(), context.read()),
|
||||
child: BlocConsumer<ProfileVerifyCubit, ProfileState>(listener: (context, snapshot) {
|
||||
if (snapshot.success) {
|
||||
pushAndReplaceToPage(context, HomeView());
|
||||
}
|
||||
}, builder: (context, snapshot) {
|
||||
//refresh the photo
|
||||
return LoadingView(
|
||||
isLoading: snapshot.loading,
|
||||
child: Scaffold(
|
||||
backgroundColor: Theme.of(context).canvasColor,
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'Verify your identity',
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
),
|
||||
AvatarImageView(
|
||||
onTap: context.read<ProfileVerifyCubit>().pickImage,
|
||||
child: snapshot.file != null
|
||||
? Image.file(
|
||||
snapshot.file,
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
: Icon(
|
||||
Icons.person_outline,
|
||||
size: 100,
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Your name',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 50.0,
|
||||
vertical: 20,
|
||||
),
|
||||
child: TextField(
|
||||
controller: context.read<ProfileVerifyCubit>().nameController,
|
||||
decoration: InputDecoration(
|
||||
fillColor: Theme.of(context).bottomNavigationBarTheme.backgroundColor,
|
||||
hintText: 'Or just how people now you',
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.grey[400],
|
||||
),
|
||||
border: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
Hero(
|
||||
tag: 'home_hero',
|
||||
child: Material(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
color: Theme.of(context).accentColor,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
context.read<ProfileVerifyCubit>().startChatting();
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 40.0,
|
||||
vertical: 15,
|
||||
),
|
||||
child: Text(
|
||||
'Start chatting now',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user