diff --git a/lib/main.dart b/lib/main.dart index 50fb8293..a99347ee 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -72,28 +72,29 @@ class MyApp extends StatelessWidget { child: BlocBuilder( builder: (context, state) { return KeyboardDismisser( - gestures: [ - GestureType.onTap, - GestureType.onPanUpdateDownDirection, + gestures: [ + GestureType.onTap, + GestureType.onPanUpdateDownDirection, + ], + child: MaterialApp.router( + theme: theme, + title: 'Eatvio', + routerConfig: AppRouter.appRouter, + debugShowCheckedModeBanner: false, + localizationsDelegates: [ + AppLocalizationDelegate(), + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, ], - child: MaterialApp.router( - theme: theme, - title: 'Eatvio', - routerConfig: AppRouter.appRouter, - debugShowCheckedModeBanner: false, - localizationsDelegates: [ - AppLocalizationDelegate(), - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - GlobalCupertinoLocalizations.delegate, - ], - supportedLocales: [ - Locale( - 'ru', - '', - ), - ], - )); + supportedLocales: [ + Locale( + 'ru', + '', + ), + ], + ), + ); }, ), ); diff --git a/lib/presentation/chat/chat_screen/bloc/chat_state.dart b/lib/presentation/chat/chat_screen/bloc/chat_state.dart index 6f5718d1..dc9dece0 100644 --- a/lib/presentation/chat/chat_screen/bloc/chat_state.dart +++ b/lib/presentation/chat/chat_screen/bloc/chat_state.dart @@ -14,6 +14,7 @@ class ChatState extends Equatable { @override List get props => [chatModelObj]; + ChatState copyWith({ChatModel? chatModelObj}) { return ChatState( chatModelObj: chatModelObj ?? this.chatModelObj, @@ -29,8 +30,8 @@ class ChatLoadedState extends ChatState { @override List get props => [chatModelObj, messages]; - ChatLoadedState copyWith( - {ChatModel? chatModelObj, List? messages}) { + + ChatLoadedState copyWith({ChatModel? chatModelObj, List? messages}) { return ChatLoadedState( chatModelObj: chatModelObj ?? this.chatModelObj, messages: messages ?? this.messages, @@ -48,6 +49,5 @@ class ChatErrorState extends ChatState { } class ChatInitialState extends ChatState { - ChatInitialState({required ChatModel chatModelObj}) - : super(chatModelObj: chatModelObj); + ChatInitialState({required ChatModel chatModelObj}) : super(chatModelObj: chatModelObj); } diff --git a/lib/presentation/chat/chat_screen/chat_screen.dart b/lib/presentation/chat/chat_screen/chat_screen.dart index 8e34fc40..3aadd095 100644 --- a/lib/presentation/chat/chat_screen/chat_screen.dart +++ b/lib/presentation/chat/chat_screen/chat_screen.dart @@ -13,10 +13,12 @@ class ChatScreen extends StatelessWidget { static Widget builder(BuildContext context, chatID) { return BlocProvider( - create: (context) => ChatBloc( - ChatState(chatModelObj: ChatModel(chatID: chatID.toString()))) - ..add(ChatInitialEvent()), - child: ChatScreen()); + create: (context) => ChatBloc(ChatState(chatModelObj: ChatModel(chatID: chatID.toString()))) + ..add( + ChatInitialEvent(), + ), + child: ChatScreen(), + ); } Widget build(BuildContext context) { @@ -24,7 +26,9 @@ class ChatScreen extends StatelessWidget { builder: (context, state) { if (state is ChatInitialState) { return Scaffold( - body: Center(child: CircularProgressIndicator(),), + body: Center( + child: CircularProgressIndicator(), + ), ); } else if (state is ChatLoadedState) { // Данные загружены, можно строить экран. @@ -34,7 +38,9 @@ class ChatScreen extends StatelessWidget { return Center(child: Text(state.errorMessage)); } else { return Scaffold( - body: Center(child: CircularProgressIndicator(),), + body: Center( + child: CircularProgressIndicator(), + ), ); } }, @@ -44,25 +50,98 @@ class ChatScreen extends StatelessWidget { _buildChat(BuildContext context, ChatLoadedState state) { mediaQueryData = MediaQuery.of(context); return Scaffold( - resizeToAvoidBottomInset: false, - appBar: _buildAppbar(context), + resizeToAvoidBottomInset: true, + appBar: _buildAppbar(context, state), body: SizedBox( width: double.maxFinite, - child: Container( - width: double.maxFinite, - decoration: AppDecoration.fillGray, - child: ListView( - children: [ - SizedBox(height: 30.v), - ], - ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + width: double.maxFinite, + decoration: AppDecoration.fillGray, + child: ListView( + shrinkWrap: true, + children: [ + for (int i = 0; i < state.messages!.length; i++) ...[Text(state.messages![i].data)] + ], + ), + ), + const Spacer(), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox(width: 8), + InkWell( + onTap: () {}, + borderRadius: BorderRadius.circular(16), + child: Ink( + height: 32, + width: 32, + child: Icon( + Icons.attach_file_rounded, + size: 28, + ), + ), + ), + SizedBox(width: 8), + SizedBox( + width: mediaQueryData.size.width - 96, + child: TextFormField( + maxLines: 5, + minLines: 1, + keyboardType: TextInputType.multiline, + decoration: InputDecoration( + contentPadding: EdgeInsets.symmetric(horizontal: 8, vertical: 0), + hintText: 'Сообщение', + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(16), + borderSide: BorderSide( + color: Color(0xFFD1D1D6), + width: 1, + ), + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(16), + borderSide: BorderSide( + color: Color(0xFFD1D1D6), + width: 1, + ), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(16), + borderSide: BorderSide( + color: Color(0xFFD1D1D6), + width: 1, + ), + ), + ), + ), + ), + SizedBox(width: 8), + InkWell( + borderRadius: BorderRadius.circular(16), + onTap: () {}, + child: Ink( + height: 32, + width: 32, + child: Icon( + Icons.send, + size: 28, + ), + ), + ), + SizedBox(width: 8), + ], + ), + ], ), ), ); } /// Section Widget - _buildAppbar(BuildContext context) { + _buildAppbar(BuildContext context, ChatLoadedState state) { return CustomAppBar( leadingWidth: 26.h, leading: AppbarLeadingImage( @@ -87,7 +166,7 @@ class ChatScreen extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ AppbarSubtitle( - text: "Валерий Леонтьев", + text: 'username', ), SizedBox(height: 3.v), Text("Был в сети вчера", style: theme.textTheme.bodySmall!) diff --git a/pubspec.yaml b/pubspec.yaml index 35f447c7..1cc0d440 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: flutter_bloc: ^8.0.0 connectivity_plus: ^5.0.2 shared_preferences: ^2.0.15 - cached_network_image: ^3.2.1 + cached_network_image: ^3.3.1 flutter_svg: ^2.0.9 equatable: ^2.0.0 validators: ^3.0.0 @@ -36,6 +36,7 @@ dev_dependencies: dart_code_metrics_presets: ^1.8.0 flutter_test: sdk: flutter + flutter: uses-material-design: true assets: