From 9fded4848480c64953a667bf450a5e0a4fd34866 Mon Sep 17 00:00:00 2001 From: stp2003 <100586951+stp2003@users.noreply.github.com> Date: Fri, 23 Feb 2024 16:12:13 +0530 Subject: [PATCH] responsive added --- lib/core/common/post_card.dart | 534 +++++++++--------- .../screens/create_community_screen.dart | 73 +-- .../screens/edit_community_screen.dart | 153 ++--- lib/features/home/screen/home_screen.dart | 5 +- lib/features/post/screen/add_post_screen.dart | 5 +- .../post/screen/add_post_type_screen.dart | 187 +++--- lib/features/post/screen/comments_screen.dart | 17 +- lib/features/post/widgets/comment_card.dart | 85 +-- lib/router.dart | 4 + web/index.html | 3 + 10 files changed, 552 insertions(+), 514 deletions(-) diff --git a/lib/core/common/post_card.dart b/lib/core/common/post_card.dart index 58d4077..ba1bab3 100644 --- a/lib/core/common/post_card.dart +++ b/lib/core/common/post_card.dart @@ -2,6 +2,7 @@ import 'package:any_link_preview/any_link_preview.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:reddit/responsive/responsive.dart'; import 'package:routemaster/routemaster.dart'; import '../../features/auth/controller/auth_controller.dart'; @@ -63,305 +64,314 @@ class PostCard extends ConsumerWidget { final currentTheme = ref.watch(themeNotifierProvider); - return Column( - children: [ - Container( - decoration: BoxDecoration( - color: currentTheme.drawerTheme.backgroundColor, - ), - padding: const EdgeInsets.symmetric(vertical: 10), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (kIsWeb) - Column( - children: [ - IconButton( - onPressed: () {}, - icon: Icon( - Constants.up, - size: 30, - color: post.upvotes.contains(user.uid) - ? Pallete.redColor - : null, + return Responsive( + child: Column( + children: [ + Container( + decoration: BoxDecoration( + color: currentTheme.drawerTheme.backgroundColor, + ), + padding: const EdgeInsets.symmetric(vertical: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (kIsWeb) + Column( + children: [ + IconButton( + onPressed: isGuest ? () {} : () => upvotePost(ref), + icon: Icon( + Constants.up, + size: 30, + color: post.upvotes.contains(user.uid) + ? Pallete.redColor + : null, + ), ), - ), - Text( - '${post.upvotes.length - post.downvotes.length == 0 ? 'Vote' : post.upvotes.length - post.downvotes.length}', - style: const TextStyle(fontSize: 17), - ), - IconButton( - onPressed: () {}, - icon: Icon( - Constants.down, - size: 30, - color: post.downvotes.contains(user.uid) - ? Pallete.blueColor - : null, + Text( + '${post.upvotes.length - post.downvotes.length == 0 ? 'Vote' : post.upvotes.length - post.downvotes.length}', + style: const TextStyle(fontSize: 17), ), - ), - ], - ), - Expanded( - child: Column( - children: [ - Container( - padding: const EdgeInsets.symmetric( - vertical: 4, - horizontal: 16, - ).copyWith(right: 0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - GestureDetector( - onTap: () => navigateToCommunity(context), - child: CircleAvatar( - backgroundImage: NetworkImage( - post.communityProfilePic, + IconButton( + onPressed: isGuest ? () {} : () => downvotePost(ref), + icon: Icon( + Constants.down, + size: 30, + color: post.downvotes.contains(user.uid) + ? Pallete.blueColor + : null, + ), + ), + ], + ), + Expanded( + child: Column( + children: [ + Container( + padding: const EdgeInsets.symmetric( + vertical: 4, + horizontal: 16, + ).copyWith(right: 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + GestureDetector( + onTap: () => navigateToCommunity(context), + child: CircleAvatar( + backgroundImage: NetworkImage( + post.communityProfilePic, + ), + radius: 16, ), - radius: 16, ), - ), - Padding( - padding: const EdgeInsets.only(left: 8), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - GestureDetector( - onTap: () => - navigateToCommunity(context), - child: Text( - 'r/${post.communityName}', - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, + Padding( + padding: const EdgeInsets.only(left: 8), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + GestureDetector( + onTap: () => + navigateToCommunity(context), + child: Text( + 'r/${post.communityName}', + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold, + ), ), ), - ), - GestureDetector( - onTap: () => navigateToUser(context), - child: Text( - 'u/${post.username}', - style: - const TextStyle(fontSize: 12), + GestureDetector( + onTap: () => + navigateToUser(context), + child: Text( + 'u/${post.username}', + style: + const TextStyle(fontSize: 12), + ), ), - ), - ], + ], + ), ), - ), - ], - ), - if (post.uid == user.uid) - IconButton( - onPressed: () => deletePost(ref, context), - icon: Icon( - Icons.delete, - color: Pallete.redColor, - ), + ], ), - ], - ), - if (post.awards.isNotEmpty) ...[ - const SizedBox(height: 5), - SizedBox( - height: 25, - child: ListView.builder( - scrollDirection: Axis.horizontal, - itemCount: post.awards.length, - itemBuilder: (BuildContext context, int index) { - final award = post.awards[index]; - return Image.asset( - Constants.awards[award]!, - height: 23, - ); - }, - ), - ), - ], - Padding( - padding: - const EdgeInsets.only(top: 10.0, bottom: 8.0), - child: Text( - post.title, - style: const TextStyle( - fontSize: 19, - fontWeight: FontWeight.bold, - ), + if (post.uid == user.uid) + IconButton( + onPressed: () => deletePost(ref, context), + icon: Icon( + Icons.delete, + color: Pallete.redColor, + ), + ), + ], ), - ), - if (isTypeImage) - SizedBox( - height: MediaQuery.of(context).size.height * 0.35, - width: double.infinity, - child: Image.network( - post.link!, - fit: BoxFit.cover, + if (post.awards.isNotEmpty) ...[ + const SizedBox(height: 5), + SizedBox( + height: 25, + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: post.awards.length, + itemBuilder: + (BuildContext context, int index) { + final award = post.awards[index]; + return Image.asset( + Constants.awards[award]!, + height: 23, + ); + }, + ), ), - ), - if (isTypeLink) + ], Padding( padding: - const EdgeInsets.symmetric(horizontal: 18), - child: AnyLinkPreview( - displayDirection: - UIDirection.uiDirectionHorizontal, - link: post.link!, - ), - ), - if (isTypeText) - Container( - alignment: Alignment.bottomLeft, - padding: - const EdgeInsets.symmetric(horizontal: 15.0), + const EdgeInsets.only(top: 10.0, bottom: 8.0), child: Text( - post.description!, + post.title, style: const TextStyle( - color: Colors.grey, + fontSize: 19, + fontWeight: FontWeight.bold, ), ), ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - if (!kIsWeb) + if (isTypeImage) + SizedBox( + height: + MediaQuery.of(context).size.height * 0.35, + width: double.infinity, + child: Image.network( + post.link!, + fit: BoxFit.cover, + ), + ), + if (isTypeLink) + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 18), + child: AnyLinkPreview( + displayDirection: + UIDirection.uiDirectionHorizontal, + link: post.link!, + ), + ), + if (isTypeText) + Container( + alignment: Alignment.bottomLeft, + padding: const EdgeInsets.symmetric( + horizontal: 15.0), + child: Text( + post.description!, + style: const TextStyle( + color: Colors.grey, + ), + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + if (!kIsWeb) + Row( + children: [ + IconButton( + onPressed: isGuest + ? () {} + : () => upvotePost(ref), + icon: Icon( + Constants.up, + size: 30, + color: post.upvotes.contains(user.uid) + ? Pallete.redColor + : null, + ), + ), + Text( + '${post.upvotes.length - post.downvotes.length == 0 ? 'Vote' : post.upvotes.length - post.downvotes.length}', + style: const TextStyle(fontSize: 17), + ), + IconButton( + onPressed: isGuest + ? () {} + : () => downvotePost(ref), + icon: Icon( + Constants.down, + size: 30, + color: + post.downvotes.contains(user.uid) + ? Pallete.blueColor + : null, + ), + ), + ], + ), Row( children: [ IconButton( - onPressed: isGuest - ? () {} - : () => upvotePost(ref), - icon: Icon( - Constants.up, - size: 30, - color: post.upvotes.contains(user.uid) - ? Pallete.redColor - : null, + onPressed: () => + navigateToComments(context), + icon: const Icon( + Icons.comment, ), ), Text( - '${post.upvotes.length - post.downvotes.length == 0 ? 'Vote' : post.upvotes.length - post.downvotes.length}', + '${post.commentCount == 0 ? 'Comment' : post.commentCount}', style: const TextStyle(fontSize: 17), ), - IconButton( - onPressed: isGuest - ? () {} - : () => downvotePost(ref), - icon: Icon( - Constants.down, - size: 30, - color: post.downvotes.contains(user.uid) - ? Pallete.blueColor - : null, - ), - ), ], ), - Row( - children: [ - IconButton( - onPressed: () => - navigateToComments(context), - icon: const Icon( - Icons.comment, - ), - ), - Text( - '${post.commentCount == 0 ? 'Comment' : post.commentCount}', - style: const TextStyle(fontSize: 17), - ), - ], - ), - ref - .watch( - getCommunityByNameProvider( - post.communityName, - ), - ) - .when( - data: (data) { - if (data.mods.contains(user.uid)) { - return IconButton( - onPressed: () => - deletePost(ref, context), - icon: const Icon( - Icons.admin_panel_settings, - ), - ); - } - return const SizedBox(); - }, - error: (error, stackTrace) => ErrorText( - error: error.toString(), + ref + .watch( + getCommunityByNameProvider( + post.communityName, + ), + ) + .when( + data: (data) { + if (data.mods.contains(user.uid)) { + return IconButton( + onPressed: () => + deletePost(ref, context), + icon: const Icon( + Icons.admin_panel_settings, + ), + ); + } + return const SizedBox(); + }, + error: (error, stackTrace) => ErrorText( + error: error.toString(), + ), + loading: () => const Loader(), ), - loading: () => const Loader(), - ), - IconButton( - onPressed: isGuest - ? () {} - : () { - showDialog( - context: context, - builder: (context) => Dialog( - child: Padding( - padding: const EdgeInsets.all(20), - child: GridView.builder( - shrinkWrap: true, - gridDelegate: - const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 4, - ), - itemCount: user.awards.length, - itemBuilder: ( - BuildContext context, - int index, - ) { - final award = - user.awards[index]; + IconButton( + onPressed: isGuest + ? () {} + : () { + showDialog( + context: context, + builder: (context) => Dialog( + child: Padding( + padding: + const EdgeInsets.all(20), + child: GridView.builder( + shrinkWrap: true, + gridDelegate: + const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 4, + ), + itemCount: user.awards.length, + itemBuilder: ( + BuildContext context, + int index, + ) { + final award = + user.awards[index]; - return GestureDetector( - onTap: () => awardPost( - ref, - award, - context, - ), - child: Padding( - padding: - const EdgeInsets.all( - 8.0, + return GestureDetector( + onTap: () => awardPost( + ref, + award, + context, ), - child: Image.asset( - Constants - .awards[award]!, + child: Padding( + padding: + const EdgeInsets + .all( + 8.0, + ), + child: Image.asset( + Constants + .awards[award]!, + ), ), - ), - ); - }, + ); + }, + ), ), ), - ), - ); - }, - icon: const Icon(Icons.card_giftcard_outlined), - ), - ], - ), - ], + ); + }, + icon: + const Icon(Icons.card_giftcard_outlined), + ), + ], + ), + ], + ), ), - ), - ], + ], + ), ), - ), - ], + ], + ), ), - ), - const SizedBox(height: 10), - ], + const SizedBox(height: 10), + ], + ), ); } } diff --git a/lib/features/community/screens/create_community_screen.dart b/lib/features/community/screens/create_community_screen.dart index bed684f..ef40bc3 100644 --- a/lib/features/community/screens/create_community_screen.dart +++ b/lib/features/community/screens/create_community_screen.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:reddit/responsive/responsive.dart'; import '../../../core/common/loader.dart'; import '../controller/community_controller.dart'; @@ -37,47 +38,49 @@ class _CreateCommunityScreenState extends ConsumerState { ), body: isLoading ? const Loader() - : Padding( - padding: const EdgeInsets.all(10.0), - child: Column( - children: [ - const Align( - alignment: Alignment.topLeft, - child: Text( - 'Community name', - style: TextStyle( - fontSize: 17.0, + : Responsive( + child: Padding( + padding: const EdgeInsets.all(10.0), + child: Column( + children: [ + const Align( + alignment: Alignment.topLeft, + child: Text( + 'Community name', + style: TextStyle( + fontSize: 17.0, + ), ), ), - ), - const SizedBox(height: 15.0), - TextField( - controller: communityNameController, - decoration: const InputDecoration( - hintText: 'r/Community_name', - filled: true, - border: InputBorder.none, - contentPadding: EdgeInsets.all(18), - ), - maxLength: 21, - ), - const SizedBox(height: 30), - ElevatedButton( - onPressed: createCommunity, - style: ElevatedButton.styleFrom( - minimumSize: const Size(double.infinity, 50), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(20), + const SizedBox(height: 15.0), + TextField( + controller: communityNameController, + decoration: const InputDecoration( + hintText: 'r/Community_name', + filled: true, + border: InputBorder.none, + contentPadding: EdgeInsets.all(18), ), + maxLength: 21, ), - child: const Text( - 'Create community', - style: TextStyle( - fontSize: 17, + const SizedBox(height: 30), + ElevatedButton( + onPressed: createCommunity, + style: ElevatedButton.styleFrom( + minimumSize: const Size(double.infinity, 50), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20), + ), + ), + child: const Text( + 'Create community', + style: TextStyle( + fontSize: 17, + ), ), ), - ), - ], + ], + ), ), ), ); diff --git a/lib/features/community/screens/edit_community_screen.dart b/lib/features/community/screens/edit_community_screen.dart index 04c3ef9..87e0279 100644 --- a/lib/features/community/screens/edit_community_screen.dart +++ b/lib/features/community/screens/edit_community_screen.dart @@ -4,6 +4,7 @@ import 'package:dotted_border/dotted_border.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:reddit/responsive/responsive.dart'; import 'package:reddit/theme/pallete.dart'; import '../../../core/common/error.dart'; @@ -109,86 +110,90 @@ class _EditCommunityScreenState extends ConsumerState { ), body: isLoading ? const Loader() - : Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - children: [ - SizedBox( - height: 200, - child: Stack( - children: [ - GestureDetector( - onTap: selectBannerImage, - child: DottedBorder( - borderType: BorderType.RRect, - radius: const Radius.circular(10), - dashPattern: const [10, 4], - strokeCap: StrokeCap.round, - color: - currentTheme.textTheme.bodyMedium!.color!, - child: Container( - width: double.infinity, - height: 150, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - ), - child: bannerWebFile != null - ? Image.memory( - bannerWebFile!, - fit: BoxFit.cover, - ) - : bannerFile != null - ? Image.file( - bannerFile!, - fit: BoxFit.cover, - ) - : community.banner.isEmpty || - community.banner == - Constants.bannerDefault - ? const Center( - child: Icon( - Icons.camera_alt_outlined, - size: 40, + : Responsive( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + children: [ + SizedBox( + height: 200, + child: Stack( + children: [ + GestureDetector( + onTap: selectBannerImage, + child: DottedBorder( + borderType: BorderType.RRect, + radius: const Radius.circular(10), + dashPattern: const [10, 4], + strokeCap: StrokeCap.round, + color: currentTheme + .textTheme.bodyMedium!.color!, + child: Container( + width: double.infinity, + height: 150, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + ), + child: bannerWebFile != null + ? Image.memory( + bannerWebFile!, + fit: BoxFit.cover, + ) + : bannerFile != null + ? Image.file( + bannerFile!, + fit: BoxFit.cover, + ) + : community.banner.isEmpty || + community.banner == + Constants + .bannerDefault + ? const Center( + child: Icon( + Icons + .camera_alt_outlined, + size: 40, + ), + ) + : Image.network( + community.banner, + fit: BoxFit.cover, ), - ) - : Image.network( - community.banner, - fit: BoxFit.cover, - ), + ), ), ), - ), - Positioned( - bottom: 20, - left: 20, - child: GestureDetector( - onTap: selectProfileImage, - child: profileWebFile != null - ? CircleAvatar( - backgroundImage: MemoryImage( - profileWebFile!, - ), - radius: 32, - ) - : profileFile != null - ? CircleAvatar( - backgroundImage: FileImage( - profileFile!, - ), - radius: 32, - ) - : CircleAvatar( - backgroundImage: NetworkImage( - community.avatar, - ), - radius: 32, + Positioned( + bottom: 20, + left: 20, + child: GestureDetector( + onTap: selectProfileImage, + child: profileWebFile != null + ? CircleAvatar( + backgroundImage: MemoryImage( + profileWebFile!, ), + radius: 32, + ) + : profileFile != null + ? CircleAvatar( + backgroundImage: FileImage( + profileFile!, + ), + radius: 32, + ) + : CircleAvatar( + backgroundImage: NetworkImage( + community.avatar, + ), + radius: 32, + ), + ), ), - ), - ], + ], + ), ), - ), - ], + ], + ), ), ), ), diff --git a/lib/features/home/screen/home_screen.dart b/lib/features/home/screen/home_screen.dart index 1727e7d..26b22a0 100644 --- a/lib/features/home/screen/home_screen.dart +++ b/lib/features/home/screen/home_screen.dart @@ -6,6 +6,7 @@ import 'package:reddit/core/constants/constants.dart'; import 'package:reddit/features/auth/controller/auth_controller.dart'; import 'package:reddit/features/home/drawers/community_list_drawer.dart'; import 'package:reddit/features/home/drawers/profile_drawer.dart'; +import 'package:routemaster/routemaster.dart'; import '../../../theme/pallete.dart'; import '../delegates/search_community_delegate.dart'; @@ -60,7 +61,9 @@ class _HomeScreenState extends ConsumerState { icon: const Icon(Icons.search), ), IconButton( - onPressed: () {}, + onPressed: () { + Routemaster.of(context).push('/add-post'); + }, icon: const Icon(Icons.add), ), Builder( diff --git a/lib/features/post/screen/add_post_screen.dart b/lib/features/post/screen/add_post_screen.dart index 0082f81..ef18806 100644 --- a/lib/features/post/screen/add_post_screen.dart +++ b/lib/features/post/screen/add_post_screen.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:routemaster/routemaster.dart'; @@ -13,8 +14,8 @@ class AddPostScreen extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - double cardHeightWidth = 120; - double iconSize = 60; + double cardHeightWidth = kIsWeb ? 360 : 120; + double iconSize = kIsWeb ? 120 : 60; final currentTheme = ref.watch(themeNotifierProvider); return Scaffold( diff --git a/lib/features/post/screen/add_post_type_screen.dart b/lib/features/post/screen/add_post_type_screen.dart index a9ae301..e84aa0b 100644 --- a/lib/features/post/screen/add_post_type_screen.dart +++ b/lib/features/post/screen/add_post_type_screen.dart @@ -4,6 +4,7 @@ import 'package:dotted_border/dotted_border.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:reddit/responsive/responsive.dart'; import '../../../core/common/error.dart'; import '../../../core/common/loader.dart'; @@ -115,109 +116,111 @@ class _AddPostTypeScreenState extends ConsumerState { ), body: isLoading ? const Loader() - : Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - children: [ - TextField( - controller: titleController, - decoration: const InputDecoration( - filled: true, - hintText: 'Enter Title here', - border: InputBorder.none, - contentPadding: EdgeInsets.all(18), - ), - maxLength: 30, - ), - const SizedBox(height: 10), - if (isTypeImage) - GestureDetector( - onTap: selectBannerImage, - child: DottedBorder( - borderType: BorderType.RRect, - radius: const Radius.circular(10), - dashPattern: const [10, 4], - strokeCap: StrokeCap.round, - color: currentTheme.textTheme.bodyMedium!.color!, - child: Container( - width: double.infinity, - height: 150, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - ), - child: bannerWebFile != null - ? Image.memory(bannerWebFile!) - : bannerFile != null - ? Image.file(bannerFile!) - : const Center( - child: Icon( - Icons.camera_alt_outlined, - size: 40, - ), - ), - ), - ), - ), - if (isTypeText) + : Responsive( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + children: [ TextField( - controller: descriptionController, + controller: titleController, decoration: const InputDecoration( filled: true, - hintText: 'Enter Description here', + hintText: 'Enter Title here', border: InputBorder.none, contentPadding: EdgeInsets.all(18), ), - maxLines: 5, + maxLength: 30, ), - if (isTypeLink) - TextField( - controller: linkController, - decoration: const InputDecoration( - filled: true, - hintText: 'Enter link here', - border: InputBorder.none, - contentPadding: EdgeInsets.all(18), + const SizedBox(height: 10), + if (isTypeImage) + GestureDetector( + onTap: selectBannerImage, + child: DottedBorder( + borderType: BorderType.RRect, + radius: const Radius.circular(10), + dashPattern: const [10, 4], + strokeCap: StrokeCap.round, + color: currentTheme.textTheme.bodyMedium!.color!, + child: Container( + width: double.infinity, + height: 150, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + ), + child: bannerWebFile != null + ? Image.memory(bannerWebFile!) + : bannerFile != null + ? Image.file(bannerFile!) + : const Center( + child: Icon( + Icons.camera_alt_outlined, + size: 40, + ), + ), + ), + ), + ), + if (isTypeText) + TextField( + controller: descriptionController, + decoration: const InputDecoration( + filled: true, + hintText: 'Enter Description here', + border: InputBorder.none, + contentPadding: EdgeInsets.all(18), + ), + maxLines: 5, + ), + if (isTypeLink) + TextField( + controller: linkController, + decoration: const InputDecoration( + filled: true, + hintText: 'Enter link here', + border: InputBorder.none, + contentPadding: EdgeInsets.all(18), + ), + ), + const SizedBox(height: 20), + const Align( + alignment: Alignment.topLeft, + child: Text( + 'Select Community', ), ), - const SizedBox(height: 20), - const Align( - alignment: Alignment.topLeft, - child: Text( - 'Select Community', - ), - ), - ref.watch(userCommunitiesProvider).when( - data: (data) { - communities = data; + ref.watch(userCommunitiesProvider).when( + data: (data) { + communities = data; - if (data.isEmpty) { - return const SizedBox(); - } - return DropdownButton( - value: selectedCommunity ?? data[0], - items: data - .map( - (e) => DropdownMenuItem( - value: e, - child: Text(e.name), - ), - ) - .toList(), - onChanged: (val) { - setState( - () { - selectedCommunity = val; - }, - ); - }, - ); - }, - error: (error, stackTrace) => ErrorText( - error: error.toString(), + if (data.isEmpty) { + return const SizedBox(); + } + return DropdownButton( + value: selectedCommunity ?? data[0], + items: data + .map( + (e) => DropdownMenuItem( + value: e, + child: Text(e.name), + ), + ) + .toList(), + onChanged: (val) { + setState( + () { + selectedCommunity = val; + }, + ); + }, + ); + }, + error: (error, stackTrace) => ErrorText( + error: error.toString(), + ), + loading: () => const Loader(), ), - loading: () => const Loader(), - ), - ], + ], + ), ), ), ); diff --git a/lib/features/post/screen/comments_screen.dart b/lib/features/post/screen/comments_screen.dart index 275b799..e27c24e 100644 --- a/lib/features/post/screen/comments_screen.dart +++ b/lib/features/post/screen/comments_screen.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:reddit/responsive/responsive.dart'; import '../../../core/common/error.dart'; import '../../../core/common/loader.dart'; @@ -56,13 +57,15 @@ class _CommentsScreenState extends ConsumerState { children: [ PostCard(post: data), if (!isGuest) - TextField( - onSubmitted: (val) => addComment(data), - controller: commentController, - decoration: const InputDecoration( - hintText: 'What are your thoughts?', - filled: true, - border: InputBorder.none, + Responsive( + child: TextField( + onSubmitted: (val) => addComment(data), + controller: commentController, + decoration: const InputDecoration( + hintText: 'What are your thoughts?', + filled: true, + border: InputBorder.none, + ), ), ), ref.watch(getPostCommentsProvider(widget.postId)).when( diff --git a/lib/features/post/widgets/comment_card.dart b/lib/features/post/widgets/comment_card.dart index ab9ba68..c5d6869 100644 --- a/lib/features/post/widgets/comment_card.dart +++ b/lib/features/post/widgets/comment_card.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:reddit/responsive/responsive.dart'; import '../../../model/comments_model.dart'; @@ -12,51 +13,53 @@ class CommentCard extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - return Container( - padding: const EdgeInsets.symmetric( - vertical: 10, - horizontal: 4, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - CircleAvatar( - backgroundImage: NetworkImage( - comment.profilePic, + return Responsive( + child: Container( + padding: const EdgeInsets.symmetric( + vertical: 10, + horizontal: 4, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + CircleAvatar( + backgroundImage: NetworkImage( + comment.profilePic, + ), + radius: 18, ), - radius: 18, - ), - Expanded( - child: Padding( - padding: const EdgeInsets.only(left: 16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'u/${comment.username}', - style: const TextStyle( - fontWeight: FontWeight.bold, + Expanded( + child: Padding( + padding: const EdgeInsets.only(left: 16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'u/${comment.username}', + style: const TextStyle( + fontWeight: FontWeight.bold, + ), ), - ), - Text(comment.text) - ], + Text(comment.text) + ], + ), ), ), - ), - ], - ), - Row( - children: [ - IconButton( - onPressed: () {}, - icon: const Icon(Icons.reply), - ), - const Text('Reply'), - ], - ), - ], + ], + ), + Row( + children: [ + IconButton( + onPressed: () {}, + icon: const Icon(Icons.reply), + ), + const Text('Reply'), + ], + ), + ], + ), ), ); } diff --git a/lib/router.dart b/lib/router.dart index e671701..3bea18b 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -8,6 +8,7 @@ import 'features/community/screens/community_screen.dart'; import 'features/community/screens/create_community_screen.dart'; import 'features/community/screens/edit_community_screen.dart'; import 'features/community/screens/mod_tools_screen.dart'; +import 'features/post/screen/add_post_screen.dart'; import 'features/post/screen/add_post_type_screen.dart'; import 'features/post/screen/comments_screen.dart'; import 'features/user_profile/screens/edit_profile_screen.dart'; @@ -69,5 +70,8 @@ final loggedInRoute = RouteMap( postId: route.pathParameters['postId']!, ), ), + '/add-post': (routeData) => const MaterialPage( + child: AddPostScreen(), + ), }, ); diff --git a/web/index.html b/web/index.html index b7a4186..001a562 100644 --- a/web/index.html +++ b/web/index.html @@ -36,6 +36,9 @@ // The value below is injected by flutter build, do not touch. const serviceWorkerVersion = null; +