diff --git a/lib/community/pages/community_page.dart b/lib/community/pages/community_page.dart index 1098b5d3e..f62162158 100644 --- a/lib/community/pages/community_page.dart +++ b/lib/community/pages/community_page.dart @@ -57,7 +57,7 @@ class _CommunityPageState extends State with AutomaticKeepAliveCl create: (context) => currentCommunityBloc = CommunityBloc(), child: BlocConsumer( listenWhen: (previousState, currentState) { - if (previousState.subscribedType != currentState.subscribedType ) { + if (previousState.subscribedType != currentState.subscribedType) { context.read().add(account_bloc.GetAccountInformation()); } diff --git a/lib/community/widgets/community_drawer.dart b/lib/community/widgets/community_drawer.dart index a8e81fe6d..48d386f57 100644 --- a/lib/community/widgets/community_drawer.dart +++ b/lib/community/widgets/community_drawer.dart @@ -177,14 +177,16 @@ class _CommunityDrawerState extends State { backgroundColor: community.icon != null ? Colors.transparent : theme.colorScheme.secondaryContainer, foregroundImage: community.icon != null ? CachedNetworkImageProvider(community.icon!) : null, maxRadius: 16, - child: community.icon == null ? Text( - community.name[0].toUpperCase(), - semanticsLabel: '', - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 16, - ), - ) : null, + child: community.icon == null + ? Text( + community.name[0].toUpperCase(), + semanticsLabel: '', + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 16, + ), + ) + : null, ), const SizedBox(width: 16.0), Expanded( diff --git a/lib/community/widgets/community_header.dart b/lib/community/widgets/community_header.dart index 5e61b552c..f9d7c1e5e 100644 --- a/lib/community/widgets/community_header.dart +++ b/lib/community/widgets/community_header.dart @@ -30,10 +30,7 @@ class CommunityHeader extends StatelessWidget { child: Container( decoration: communityInfo?.communityView.community.banner != null ? BoxDecoration( - image: DecorationImage( - image: CachedNetworkImageProvider( - communityInfo!.communityView.community.banner!), - fit: BoxFit.cover), + image: DecorationImage(image: CachedNetworkImageProvider(communityInfo!.communityView.community.banner!), fit: BoxFit.cover), ) : null, child: Container( @@ -53,8 +50,7 @@ class CommunityHeader extends StatelessWidget { ) : null, child: Padding( - padding: const EdgeInsets.only( - top: 16.0, left: 24.0, right: 24.0, bottom: 16.0), + padding: const EdgeInsets.only(top: 16.0, left: 24.0, right: 24.0, bottom: 16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, @@ -62,17 +58,8 @@ class CommunityHeader extends StatelessWidget { Row( children: [ CircleAvatar( - backgroundColor: - communityInfo?.communityView.community.icon != - null - ? Colors.transparent - : theme.colorScheme.onBackground, - foregroundImage: communityInfo - ?.communityView.community.icon != - null - ? CachedNetworkImageProvider( - communityInfo!.communityView.community.icon!) - : null, + backgroundColor: communityInfo?.communityView.community.icon != null ? Colors.transparent : theme.colorScheme.onBackground, + foregroundImage: communityInfo?.communityView.community.icon != null ? CachedNetworkImageProvider(communityInfo!.communityView.community.icon!) : null, maxRadius: 45, ), const SizedBox(width: 20.0), @@ -82,12 +69,8 @@ class CommunityHeader extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Text( - communityInfo?.communityView.community.title ?? - communityInfo - ?.communityView.community.name ?? - 'N/A', - style: theme.textTheme.headlineSmall - ?.copyWith(fontWeight: FontWeight.w600), + communityInfo?.communityView.community.title ?? communityInfo?.communityView.community.name ?? 'N/A', + style: theme.textTheme.headlineSmall?.copyWith(fontWeight: FontWeight.w600), ), Text('${communityInfo?.communityView.community.name ?? 'N/A'}@${fetchInstanceNameFromUrl(communityInfo?.communityView.community.actorId) ?? 'N/A'}'), const SizedBox(height: 8.0), @@ -95,21 +78,12 @@ class CommunityHeader extends StatelessWidget { children: [ IconText( icon: const Icon(Icons.people_rounded), - text: formatNumberToK(communityInfo - ?.communityView - .counts - .subscribers ?? - 0), + text: formatNumberToK(communityInfo?.communityView.counts.subscribers ?? 0), ), const SizedBox(width: 8.0), IconText( - icon: const Icon( - Icons.calendar_month_rounded), - text: formatNumberToK(communityInfo - ?.communityView - .counts - .usersActiveMonth ?? - 0), + icon: const Icon(Icons.calendar_month_rounded), + text: formatNumberToK(communityInfo?.communityView.counts.usersActiveMonth ?? 0), ), ], ), @@ -117,13 +91,9 @@ class CommunityHeader extends StatelessWidget { ), ), Icon( - isSidebarOpen != null && isSidebarOpen! - ? Icons.chevron_right_rounded - : Icons.chevron_left_rounded, + isSidebarOpen != null && isSidebarOpen! ? Icons.chevron_right_rounded : Icons.chevron_left_rounded, size: 50, - shadows: const [ - Shadow(color: Colors.black, blurRadius: 5.0) - ], + shadows: const [Shadow(color: Colors.black, blurRadius: 5.0)], ) ], ), diff --git a/lib/community/widgets/community_sidebar.dart b/lib/community/widgets/community_sidebar.dart index fed7d6d73..6cf8545c4 100644 --- a/lib/community/widgets/community_sidebar.dart +++ b/lib/community/widgets/community_sidebar.dart @@ -22,7 +22,6 @@ import '../pages/create_post_page.dart'; import 'community_header.dart'; class CommunitySidebar extends StatefulWidget { - final FullCommunityView? communityInfo; final SubscribedType? subscribedType; final BlockedCommunity? blockedCommunity; @@ -38,7 +37,7 @@ class CommunitySidebar extends StatefulWidget { State createState() => _CommunitySidebarState(); } -class _CommunitySidebarState extends State with TickerProviderStateMixin{ +class _CommunitySidebarState extends State with TickerProviderStateMixin { final ScrollController _scrollController = ScrollController(); bool isBlocked = false; @@ -59,7 +58,7 @@ class _CommunitySidebarState extends State with TickerProvider final theme = Theme.of(context); final bool isUserLoggedIn = context.read().state.isLoggedIn; - if( widget.blockedCommunity != null ) { + if (widget.blockedCommunity != null) { isBlocked = widget.blockedCommunity!.blocked; } else { isBlocked = widget.communityInfo!.communityView.blocked; @@ -76,154 +75,183 @@ class _CommunitySidebarState extends State with TickerProvider child: Column( children: [ AnimatedSwitcher( - duration: const Duration( milliseconds: 100), + duration: const Duration(milliseconds: 100), transitionBuilder: (Widget child, Animation animation) { return SizeTransition( sizeFactor: animation, child: FadeTransition(opacity: animation, child: child), ); }, - child: isBlocked == false ? Padding( - padding: const EdgeInsets.only(top: 8.0, left: 12, right: 12,), - child: Row( - children: [ - Expanded( - child: ElevatedButton( - onPressed: isUserLoggedIn ? () { - HapticFeedback.mediumImpact(); - CommunityBloc communityBloc = context.read(); - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) { - return BlocProvider.value( - value: communityBloc, - child: CreatePostPage(communityId: widget.communityInfo!.communityView.community.id, communityInfo: widget.communityInfo), - ); - }, - ), - ); - } : null, - style: TextButton.styleFrom( - fixedSize: const Size.fromHeight(40), - foregroundColor: null, - padding: EdgeInsets.zero, - ), - child: const Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - Icons.library_books_rounded, - semanticLabel: 'New Post', + child: isBlocked == false + ? Padding( + padding: const EdgeInsets.only( + top: 8.0, + left: 12, + right: 12, + ), + child: Row( + children: [ + Expanded( + child: ElevatedButton( + onPressed: isUserLoggedIn + ? () { + HapticFeedback.mediumImpact(); + CommunityBloc communityBloc = context.read(); + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) { + return BlocProvider.value( + value: communityBloc, + child: CreatePostPage(communityId: widget.communityInfo!.communityView.community.id, communityInfo: widget.communityInfo), + ); + }, + ), + ); + } + : null, + style: TextButton.styleFrom( + fixedSize: const Size.fromHeight(40), + foregroundColor: null, + padding: EdgeInsets.zero, + ), + child: const Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.library_books_rounded, + semanticLabel: 'New Post', + ), + SizedBox(width: 4.0), + Text( + 'New Post', + style: TextStyle( + color: null, + ), + ), + ], + ), ), - SizedBox(width: 4.0), - Text( - 'New Post', - style: TextStyle( - color: null, + ), + const SizedBox( + width: 8, + height: 8, + ), + Expanded( + child: ElevatedButton( + onPressed: isUserLoggedIn + ? () { + HapticFeedback.mediumImpact(); + context.read().add( + ChangeCommunitySubsciptionStatusEvent( + communityId: widget.communityInfo!.communityView.community.id, + follow: (widget.subscribedType == null) ? true : (widget.subscribedType == SubscribedType.notSubscribed ? true : false), + ), + ); + } + : null, + style: TextButton.styleFrom( + fixedSize: const Size.fromHeight(40), + foregroundColor: null, + padding: EdgeInsets.zero, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + switch (widget.subscribedType) { + SubscribedType.notSubscribed => Icons.add_circle_outline_rounded, + SubscribedType.pending => Icons.pending_outlined, + SubscribedType.subscribed => Icons.remove_circle_outline_rounded, + _ => Icons.add_circle_outline_rounded, + }, + semanticLabel: (widget.subscribedType == SubscribedType.notSubscribed || widget.subscribedType == null) ? 'Subscribe' : 'Unsubscribe', + ), + const SizedBox(width: 4.0), + Text( + switch (widget.subscribedType) { + SubscribedType.notSubscribed => 'Subscribe', + SubscribedType.pending => 'Pending...', + SubscribedType.subscribed => 'Unsubscribe', + _ => '', + }, + ), + ], ), ), - ], - ), + ), + ], + ), + ) + : null, + ), + AnimatedSwitcher( + duration: const Duration(milliseconds: 150), + transitionBuilder: (Widget child, Animation animation) { + return SizeTransition( + sizeFactor: animation, + child: FadeTransition(opacity: animation, child: child), + ); + }, + child: widget.subscribedType != SubscribedType.subscribed + ? Padding( + padding: const EdgeInsets.only( + top: 8.0, + left: 12, + right: 12, ), - ), - const SizedBox( width: 8, height: 8,), - Expanded( child: ElevatedButton( - onPressed: isUserLoggedIn ? () { - HapticFeedback.mediumImpact(); - context.read().add( - ChangeCommunitySubsciptionStatusEvent( - communityId: widget.communityInfo!.communityView.community.id, - follow: (widget.subscribedType == null) ? true : (widget.subscribedType == SubscribedType.notSubscribed ? true : false), - ), - ); - } : null, + onPressed: isUserLoggedIn + ? () { + HapticFeedback.heavyImpact(); + ScaffoldMessenger.of(context).clearSnackBars(); + context.read().add( + BlockCommunityEvent( + communityId: widget.communityInfo!.communityView.community.id, + block: isBlocked == true ? false : true, + ), + ); + } + : null, style: TextButton.styleFrom( fixedSize: const Size.fromHeight(40), - foregroundColor: null, + foregroundColor: Colors.redAccent, padding: EdgeInsets.zero, ), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( - switch (widget.subscribedType) { - SubscribedType.notSubscribed => Icons.add_circle_outline_rounded, - SubscribedType.pending => Icons.pending_outlined, - SubscribedType.subscribed => Icons.remove_circle_outline_rounded, - _ => Icons.add_circle_outline_rounded, - }, - semanticLabel: (widget.subscribedType == SubscribedType.notSubscribed || widget.subscribedType == null) ? 'Subscribe' : 'Unsubscribe', + isBlocked == true ? Icons.undo_rounded : Icons.block_rounded, + semanticLabel: isBlocked == true ? 'Unblock Community' : 'Block Community', ), const SizedBox(width: 4.0), - Text( switch (widget.subscribedType) { - SubscribedType.notSubscribed => 'Subscribe', - SubscribedType.pending => 'Pending...', - SubscribedType.subscribed => 'Unsubscribe', - _ => '', - }, + Text( + isBlocked == true ? 'Unblock Community' : 'Block Community', ), ], ), ), - ), - ], - ), - ) : null, - ), - AnimatedSwitcher( - duration: const Duration( milliseconds: 150), - transitionBuilder: (Widget child, Animation animation) { - return SizeTransition( - sizeFactor: animation, - child: FadeTransition(opacity: animation, child: child), - ); - }, - child: widget.subscribedType != SubscribedType.subscribed ? Padding( - padding: const EdgeInsets.only(top: 8.0, left: 12, right: 12,), - child: ElevatedButton( - onPressed: isUserLoggedIn ? () { - HapticFeedback.heavyImpact(); - ScaffoldMessenger.of(context).clearSnackBars(); - context.read().add( - BlockCommunityEvent( - communityId: widget.communityInfo!.communityView.community.id, - block: isBlocked == true ? false : true, - ), - ); - } : null, - style: TextButton.styleFrom( - fixedSize: const Size.fromHeight(40), - foregroundColor: Colors.redAccent, - padding: EdgeInsets.zero, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - isBlocked == true ? Icons.undo_rounded : Icons.block_rounded, - semanticLabel: isBlocked == true ? 'Unblock Community' : 'Block Community', - ), - const SizedBox(width: 4.0), - Text( - isBlocked == true ? 'Unblock Community' : 'Block Community', - ), - ], - ), - ), - ) : null, + ) + : null, ), const Divider(), Expanded( child: ListView( children: [ Padding( - padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8,), + padding: const EdgeInsets.symmetric( + horizontal: 12.0, + vertical: 8, + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: const EdgeInsets.only(left: 8.0, right: 8, bottom: 8,), + padding: const EdgeInsets.only( + left: 8.0, + right: 8, + bottom: 8, + ), child: CommonMarkdownBody( body: widget.communityInfo?.communityView.community.description ?? '', ), @@ -239,11 +267,15 @@ class _CommunitySidebarState extends State with TickerProvider children: [ Padding( padding: const EdgeInsets.only(right: 8, top: 2, bottom: 2), - child: Icon( Icons.cake_rounded, size: 18, color: theme.colorScheme.onBackground.withOpacity(0.65),), + child: Icon( + Icons.cake_rounded, + size: 18, + color: theme.colorScheme.onBackground.withOpacity(0.65), + ), ), Text( 'Created ${DateFormat.yMMMMd().format(widget.communityInfo!.communityView.community.published)} · ${formatTimeToString(dateTime: widget.communityInfo!.communityView.community.published.toIso8601String())} ago', - style: TextStyle( color: theme.colorScheme.onBackground.withOpacity(0.65)), + style: TextStyle(color: theme.colorScheme.onBackground.withOpacity(0.65)), ), ], ), @@ -252,11 +284,15 @@ class _CommunitySidebarState extends State with TickerProvider children: [ Padding( padding: const EdgeInsets.only(right: 8, top: 2, bottom: 2), - child: Icon( Icons.people_rounded, size: 18, color: theme.colorScheme.onBackground.withOpacity(0.65),), + child: Icon( + Icons.people_rounded, + size: 18, + color: theme.colorScheme.onBackground.withOpacity(0.65), + ), ), Text( '${NumberFormat("#,###,###,###").format(widget.communityInfo?.communityView.counts.subscribers)} Subscribers', - style: TextStyle( color: theme.textTheme.titleSmall?.color?.withOpacity(0.65) ), + style: TextStyle(color: theme.textTheme.titleSmall?.color?.withOpacity(0.65)), ), ], ), @@ -264,11 +300,15 @@ class _CommunitySidebarState extends State with TickerProvider children: [ Padding( padding: const EdgeInsets.only(right: 8, top: 2, bottom: 2), - child: Icon( Icons.wysiwyg_rounded, size: 18, color: theme.colorScheme.onBackground.withOpacity(0.65),), + child: Icon( + Icons.wysiwyg_rounded, + size: 18, + color: theme.colorScheme.onBackground.withOpacity(0.65), + ), ), Text( '${NumberFormat("#,###,###,###").format(widget.communityInfo?.communityView.counts.posts)} Posts', - style: TextStyle( color: theme.textTheme.titleSmall?.color?.withOpacity(0.65) ), + style: TextStyle(color: theme.textTheme.titleSmall?.color?.withOpacity(0.65)), ), ], ), @@ -276,11 +316,15 @@ class _CommunitySidebarState extends State with TickerProvider children: [ Padding( padding: const EdgeInsets.only(right: 8, top: 2, bottom: 2), - child: Icon( Icons.chat_rounded, size: 18, color: theme.colorScheme.onBackground.withOpacity(0.65),), + child: Icon( + Icons.chat_rounded, + size: 18, + color: theme.colorScheme.onBackground.withOpacity(0.65), + ), ), Text( '${NumberFormat("#,###,###,###").format(widget.communityInfo?.communityView.counts.comments)} Comments', - style: TextStyle( color: theme.textTheme.titleSmall?.color?.withOpacity(0.65) ), + style: TextStyle(color: theme.textTheme.titleSmall?.color?.withOpacity(0.65)), ), ], ), @@ -289,11 +333,15 @@ class _CommunitySidebarState extends State with TickerProvider children: [ Padding( padding: const EdgeInsets.only(right: 8, top: 2, bottom: 2), - child: Icon( Icons.calendar_month_rounded, size: 18, color: theme.colorScheme.onBackground.withOpacity(0.65),), + child: Icon( + Icons.calendar_month_rounded, + size: 18, + color: theme.colorScheme.onBackground.withOpacity(0.65), + ), ), Text( '${NumberFormat("#,###,###,###").format(widget.communityInfo?.communityView.counts.usersActiveHalfYear)} users in six months', - style: TextStyle( color: theme.textTheme.titleSmall?.color?.withOpacity(0.65) ), + style: TextStyle(color: theme.textTheme.titleSmall?.color?.withOpacity(0.65)), ), ], ), @@ -301,11 +349,15 @@ class _CommunitySidebarState extends State with TickerProvider children: [ Padding( padding: const EdgeInsets.only(right: 8, top: 2, bottom: 2), - child: Icon( Icons.calendar_view_month_rounded, size: 18, color: theme.colorScheme.onBackground.withOpacity(0.65),), + child: Icon( + Icons.calendar_view_month_rounded, + size: 18, + color: theme.colorScheme.onBackground.withOpacity(0.65), + ), ), Text( '${NumberFormat("#,###,###,###").format(widget.communityInfo?.communityView.counts.usersActiveMonth)} users a month', - style: TextStyle( color: theme.textTheme.titleSmall?.color?.withOpacity(0.65) ), + style: TextStyle(color: theme.textTheme.titleSmall?.color?.withOpacity(0.65)), ), ], ), @@ -313,11 +365,15 @@ class _CommunitySidebarState extends State with TickerProvider children: [ Padding( padding: const EdgeInsets.only(right: 8, top: 2, bottom: 2), - child: Icon( Icons.calendar_view_week_rounded, size: 18, color: theme.colorScheme.onBackground.withOpacity(0.65),), + child: Icon( + Icons.calendar_view_week_rounded, + size: 18, + color: theme.colorScheme.onBackground.withOpacity(0.65), + ), ), Text( '${NumberFormat("#,###,###,###").format(widget.communityInfo?.communityView.counts.usersActiveWeek)} users a week', - style: TextStyle( color: theme.textTheme.titleSmall?.color?.withOpacity(0.65) ), + style: TextStyle(color: theme.textTheme.titleSmall?.color?.withOpacity(0.65)), ), ], ), @@ -325,11 +381,15 @@ class _CommunitySidebarState extends State with TickerProvider children: [ Padding( padding: const EdgeInsets.only(right: 8, top: 2, bottom: 2), - child: Icon( Icons.calendar_view_day_rounded, size: 18, color: theme.colorScheme.onBackground.withOpacity(0.65),), + child: Icon( + Icons.calendar_view_day_rounded, + size: 18, + color: theme.colorScheme.onBackground.withOpacity(0.65), + ), ), Text( '${NumberFormat("#,###,###,###").format(widget.communityInfo?.communityView.counts.usersActiveDay)} users a day', - style: TextStyle( color: theme.textTheme.titleSmall?.color?.withOpacity(0.65) ), + style: TextStyle(color: theme.textTheme.titleSmall?.color?.withOpacity(0.65)), ), ], ), @@ -342,100 +402,43 @@ class _CommunitySidebarState extends State with TickerProvider Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0), child: Column( - children: [ for (var mods in widget.communityInfo!.moderators) - GestureDetector( - onTap: () { - account_bloc.AccountBloc accountBloc = context.read(); - AuthBloc authBloc = context.read(); - ThunderBloc thunderBloc = context.read(); + children: [ + for (var mods in widget.communityInfo!.moderators) + GestureDetector( + onTap: () { + account_bloc.AccountBloc accountBloc = context.read(); + AuthBloc authBloc = context.read(); + ThunderBloc thunderBloc = context.read(); - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => MultiBlocProvider( - providers: [ - BlocProvider.value(value: accountBloc), - BlocProvider.value(value: authBloc), - BlocProvider.value(value: thunderBloc), - ], - child: UserPage(userId: mods.moderator!.id), - ), - ), - ); - }, - child: Padding( - padding: const EdgeInsets.only(bottom: 8.0), - child: Row( - children: [ - CircleAvatar( - backgroundColor: mods.moderator?.avatar != null ? Colors.transparent : theme.colorScheme.secondaryContainer, - foregroundImage: mods.moderator?.avatar != null ? CachedNetworkImageProvider( mods.moderator!.avatar! ) : null, - maxRadius: 20, - child: Text( - mods.moderator!.name[0].toUpperCase() ?? '', - semanticsLabel: '', - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 16, - ), - ), - ), - const SizedBox(width: 16.0), - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - mods.moderator!.displayName ?? mods.moderator!.name ?? '', - overflow: TextOverflow.ellipsis, - maxLines: 1, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 16, - ), - ), - Text( - '${mods.moderator!.name ?? ''} · ${fetchInstanceNameFromUrl(mods.moderator!.actorId)}', - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: theme.colorScheme.onBackground.withOpacity(0.6), - fontSize: 13, - ), - ), + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => MultiBlocProvider( + providers: [ + BlocProvider.value(value: accountBloc), + BlocProvider.value(value: authBloc), + BlocProvider.value(value: thunderBloc), ], + child: UserPage(userId: mods.moderator!.id), ), ), - ], - ), - ), - ), - ], - ), - ), - Container( - child: widget.communityInfo?.site != null ? Column( - children: [ - const SizedBox(height: 40), - const Text('Community host instance:'), - const Divider(), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 8.0), - child: Column( - children: [ - Row( + ); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: 8.0), + child: Row( children: [ CircleAvatar( - backgroundColor: widget.communityInfo?.site?.icon != null ? Colors.transparent : theme.colorScheme.secondaryContainer, - foregroundImage: widget.communityInfo?.site?.icon != null ? CachedNetworkImageProvider( widget.communityInfo!.site!.icon! ) : null, - maxRadius: 24, - child: widget.communityInfo?.site?.icon == null ? Text( - widget.communityInfo?.moderators.first.moderator!.name[0].toUpperCase() ?? '', + backgroundColor: mods.moderator?.avatar != null ? Colors.transparent : theme.colorScheme.secondaryContainer, + foregroundImage: mods.moderator?.avatar != null ? CachedNetworkImageProvider(mods.moderator!.avatar!) : null, + maxRadius: 20, + child: Text( + mods.moderator!.name[0].toUpperCase() ?? '', semanticsLabel: '', style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 16, ), - ) : null, + ), ), const SizedBox(width: 16.0), Expanded( @@ -444,35 +447,99 @@ class _CommunitySidebarState extends State with TickerProvider crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - widget.communityInfo?.site?.name ?? /*widget.communityInfo?.instanceHost ??*/ '', + mods.moderator!.displayName ?? mods.moderator!.name ?? '', overflow: TextOverflow.ellipsis, maxLines: 1, - style: theme.textTheme.headlineSmall?.copyWith(fontWeight: FontWeight.w600), + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 16, + ), ), Text( - widget.communityInfo?.site?.description ?? '', - style: theme.textTheme.bodyMedium, - overflow: TextOverflow.visible, + '${mods.moderator!.name ?? ''} · ${fetchInstanceNameFromUrl(mods.moderator!.actorId)}', + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: theme.colorScheme.onBackground.withOpacity(0.6), + fontSize: 13, + ), ), ], ), ), ], ), + ), + ), + ], + ), + ), + Container( + child: widget.communityInfo?.site != null + ? Column( + children: [ + const SizedBox(height: 40), + const Text('Community host instance:'), const Divider(), - CommonMarkdownBody( - body: widget.communityInfo?.site?.sidebar ?? '' /*?? widget.communityInfo?.instanceHost*/, + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8.0), + child: Column( + children: [ + Row( + children: [ + CircleAvatar( + backgroundColor: widget.communityInfo?.site?.icon != null ? Colors.transparent : theme.colorScheme.secondaryContainer, + foregroundImage: widget.communityInfo?.site?.icon != null ? CachedNetworkImageProvider(widget.communityInfo!.site!.icon!) : null, + maxRadius: 24, + child: widget.communityInfo?.site?.icon == null + ? Text( + widget.communityInfo?.moderators.first.moderator!.name[0].toUpperCase() ?? '', + semanticsLabel: '', + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 16, + ), + ) + : null, + ), + const SizedBox(width: 16.0), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.communityInfo?.site?.name ?? /*widget.communityInfo?.instanceHost ??*/ '', + overflow: TextOverflow.ellipsis, + maxLines: 1, + style: theme.textTheme.headlineSmall?.copyWith(fontWeight: FontWeight.w600), + ), + Text( + widget.communityInfo?.site?.description ?? '', + style: theme.textTheme.bodyMedium, + overflow: TextOverflow.visible, + ), + ], + ), + ), + ], + ), + const Divider(), + CommonMarkdownBody( + body: widget.communityInfo?.site?.sidebar ?? '' /*?? widget.communityInfo?.instanceHost*/, + ), + ], + ), ), ], - ), - ), - ], - ) : null, + ) + : null, ), ], ), ), - const SizedBox(height: 128,) + const SizedBox( + height: 128, + ) ], ), ), diff --git a/lib/community/widgets/post_card_list.dart b/lib/community/widgets/post_card_list.dart index ad656f835..7c64c9e66 100644 --- a/lib/community/widgets/post_card_list.dart +++ b/lib/community/widgets/post_card_list.dart @@ -53,7 +53,7 @@ class PostCardList extends StatefulWidget { State createState() => _PostCardListState(); } -class _PostCardListState extends State with TickerProviderStateMixin{ +class _PostCardListState extends State with TickerProviderStateMixin { bool _displaySidebar = false; final _scrollController = ScrollController(initialScrollOffset: 0); bool _showReturnToTopButton = false; @@ -159,7 +159,7 @@ class _PostCardListState extends State with TickerProviderStateMix }); }, onHorizontalDragUpdate: (details) { - if( details.delta.dx < -3) { + if (details.delta.dx < -3) { setState(() { _displaySidebar = true; }); @@ -208,7 +208,7 @@ class _PostCardListState extends State with TickerProviderStateMix ), GestureDetector( onHorizontalDragUpdate: (details) { - if( details.delta.dx > 3) { + if (details.delta.dx > 3) { setState(() { _displaySidebar = false; }); @@ -218,43 +218,55 @@ class _PostCardListState extends State with TickerProviderStateMix children: [ AnimatedSwitcher( duration: const Duration(milliseconds: 300), - child: _displaySidebar ? GestureDetector( - onTap: () { - setState(() { - _displaySidebar = false; - }); - }, - child: CommunityHeader(communityInfo: widget.communityInfo, isSidebarOpen: _displaySidebar,), - ) : null, - ), - Expanded( - child: Stack( - children: [ - AnimatedSwitcher( - duration: const Duration(milliseconds: 300), - child: _displaySidebar ? GestureDetector( + child: _displaySidebar + ? GestureDetector( onTap: () { setState(() { _displaySidebar = false; }); }, - child: Container( - color: Colors.black.withOpacity(0.75), + child: CommunityHeader( + communityInfo: widget.communityInfo, + isSidebarOpen: _displaySidebar, ), - ) : null, + ) + : null, + ), + Expanded( + child: Stack( + children: [ + AnimatedSwitcher( + duration: const Duration(milliseconds: 300), + child: _displaySidebar + ? GestureDetector( + onTap: () { + setState(() { + _displaySidebar = false; + }); + }, + child: Container( + color: Colors.black.withOpacity(0.75), + ), + ) + : null, ), AnimatedSwitcher( switchInCurve: Curves.decelerate, switchOutCurve: Curves.easeOut, transitionBuilder: (child, animation) { return SlideTransition( - position: Tween(begin: const Offset(1.2, 0), end: const Offset(0, 0)) - .animate(animation), + position: Tween(begin: const Offset(1.2, 0), end: const Offset(0, 0)).animate(animation), child: child, ); }, duration: const Duration(milliseconds: 300), - child: _displaySidebar ? CommunitySidebar(communityInfo: widget.communityInfo, subscribedType: widget.subscribeType, blockedCommunity: widget.blockedCommunity,) : null, + child: _displaySidebar + ? CommunitySidebar( + communityInfo: widget.communityInfo, + subscribedType: widget.subscribeType, + blockedCommunity: widget.blockedCommunity, + ) + : null, ), ], ), diff --git a/lib/post/widgets/post_view.dart b/lib/post/widgets/post_view.dart index 8f0504887..38c1196f2 100644 --- a/lib/post/widgets/post_view.dart +++ b/lib/post/widgets/post_view.dart @@ -90,7 +90,9 @@ class PostSubview extends StatelessWidget { BlocProvider.value(value: authBloc), BlocProvider.value(value: thunderBloc), ], - child: UserPage(userId: postView.creator.id,), + child: UserPage( + userId: postView.creator.id, + ), ), ), ); diff --git a/lib/search/pages/search_page.dart b/lib/search/pages/search_page.dart index 5e9ad1b4a..2c74c6928 100644 --- a/lib/search/pages/search_page.dart +++ b/lib/search/pages/search_page.dart @@ -217,14 +217,16 @@ class _SearchPageState extends State { backgroundColor: communityView.community.icon != null ? Colors.transparent : theme.colorScheme.primaryContainer, foregroundImage: communityView.community.icon != null ? CachedNetworkImageProvider(communityView.community.icon!) : null, maxRadius: 25, - child: communityView.community.icon == null ? Text( - communityView.community.name[0].toUpperCase(), - semanticsLabel: '', - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 25, - ), - ) : null, + child: communityView.community.icon == null + ? Text( + communityView.community.name[0].toUpperCase(), + semanticsLabel: '', + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 25, + ), + ) + : null, ), title: Text( communityView.community.title, diff --git a/lib/user/bloc/user_event.dart b/lib/user/bloc/user_event.dart index 23e8af391..3416984c3 100644 --- a/lib/user/bloc/user_event.dart +++ b/lib/user/bloc/user_event.dart @@ -63,4 +63,4 @@ class BlockUserEvent extends UserEvent { final bool blocked; const BlockUserEvent({required this.personId, required this.blocked}); -} \ No newline at end of file +} diff --git a/lib/user/bloc/user_state.dart b/lib/user/bloc/user_state.dart index c25438451..1eda2937e 100644 --- a/lib/user/bloc/user_state.dart +++ b/lib/user/bloc/user_state.dart @@ -3,7 +3,6 @@ part of 'user_bloc.dart'; enum UserStatus { initial, loading, refreshing, success, empty, failure } class UserState extends Equatable { - const UserState({ this.status = UserStatus.initial, this.userId, @@ -92,19 +91,20 @@ class UserState extends Equatable { @override List get props => [ - status, - userId, - personView, - comments, - posts, - page, - savedPosts, - moderates, - errorMessage, - hasReachedPostEnd, - hasReachedSavedPostEnd, - hasReachedCommentEnd, - hasReachedSavedCommentEnd, - personBlocks, - blockedPerson]; + status, + userId, + personView, + comments, + posts, + page, + savedPosts, + moderates, + errorMessage, + hasReachedPostEnd, + hasReachedSavedPostEnd, + hasReachedCommentEnd, + hasReachedSavedCommentEnd, + personBlocks, + blockedPerson + ]; } diff --git a/lib/user/pages/user_page.dart b/lib/user/pages/user_page.dart index 240867854..8d8a2eef9 100644 --- a/lib/user/pages/user_page.dart +++ b/lib/user/pages/user_page.dart @@ -23,7 +23,6 @@ class UserPage extends StatefulWidget { class _UserPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( appBar: AppBar( scrolledUnderElevation: 0, @@ -82,8 +81,7 @@ class _UserPageState extends State { ), body: MultiBlocProvider( providers: [ - BlocProvider( - create: (BuildContext context) => UserBloc()), + BlocProvider(create: (BuildContext context) => UserBloc()), BlocProvider(create: (context) => community.CommunityBloc()), ], child: BlocBuilder(builder: (context, state) { @@ -114,8 +112,7 @@ class _UserPageState extends State { return ErrorMessage( message: state.errorMessage, action: () { - context.read().add(GetUserEvent(userId: widget - .userId, reset: true)); + context.read().add(GetUserEvent(userId: widget.userId, reset: true)); }, actionText: 'Refresh Content', ); diff --git a/lib/user/pages/user_page_success.dart b/lib/user/pages/user_page_success.dart index 7c5909697..fae35a79b 100644 --- a/lib/user/pages/user_page_success.dart +++ b/lib/user/pages/user_page_success.dart @@ -114,7 +114,7 @@ class _UserPageSuccessState extends State with TickerProviderSt }); }, onHorizontalDragUpdate: (details) { - if( details.delta.dx < -3) { + if (details.delta.dx < -3) { setState(() { _displaySidebar = true; }); @@ -183,7 +183,7 @@ class _UserPageSuccessState extends State with TickerProviderSt ), GestureDetector( onHorizontalDragUpdate: (details) { - if( details.delta.dx > 3) { + if (details.delta.dx > 3) { setState(() { _displaySidebar = false; }); @@ -193,43 +193,56 @@ class _UserPageSuccessState extends State with TickerProviderSt children: [ AnimatedSwitcher( duration: const Duration(milliseconds: 300), - child: _displaySidebar ? GestureDetector( - onTap: () { - setState(() { - _displaySidebar = false; - }); - }, - child: UserHeader(userInfo: widget.personView, isSidebarOpen: _displaySidebar,), - ) : null, - ), - Expanded( - child: Stack( - children: [ - AnimatedSwitcher( - duration: const Duration(milliseconds: 300), - child: _displaySidebar ? GestureDetector( + child: _displaySidebar + ? GestureDetector( onTap: () { setState(() { _displaySidebar = false; }); }, - child: Container( - color: Colors.black.withOpacity(0.75), + child: UserHeader( + userInfo: widget.personView, + isSidebarOpen: _displaySidebar, ), - ) : null, + ) + : null, + ), + Expanded( + child: Stack( + children: [ + AnimatedSwitcher( + duration: const Duration(milliseconds: 300), + child: _displaySidebar + ? GestureDetector( + onTap: () { + setState(() { + _displaySidebar = false; + }); + }, + child: Container( + color: Colors.black.withOpacity(0.75), + ), + ) + : null, ), AnimatedSwitcher( switchInCurve: Curves.decelerate, switchOutCurve: Curves.easeOut, transitionBuilder: (child, animation) { return SlideTransition( - position: Tween(begin: const Offset(1.2, 0), end: const Offset(0, 0)) - .animate(animation), + position: Tween(begin: const Offset(1.2, 0), end: const Offset(0, 0)).animate(animation), child: child, ); }, duration: const Duration(milliseconds: 300), - child: _displaySidebar ? UserSidebar(userInfo: widget.personView, moderates: widget.moderates, isAccountUser: widget.isAccountUser, blockedPerson: widget.blockedPerson,) : null, + child: _displaySidebar + ? UserSidebar( + userInfo: widget.personView, + moderates: widget.moderates, + isAccountUser: widget.isAccountUser, + blockedPerson: widget.blockedPerson, + ) + : null, ), ], ), diff --git a/lib/user/widgets/user_header.dart b/lib/user/widgets/user_header.dart index 96d1de0b1..8975b5fef 100644 --- a/lib/user/widgets/user_header.dart +++ b/lib/user/widgets/user_header.dart @@ -48,8 +48,7 @@ class UserHeader extends StatelessWidget { ) : null, child: Padding( - padding: const EdgeInsets.only( - top: 16.0, left: 24.0, right: 24.0, bottom: 16.0), + padding: const EdgeInsets.only(top: 16.0, left: 24.0, right: 24.0, bottom: 16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, @@ -57,12 +56,8 @@ class UserHeader extends StatelessWidget { Row( children: [ CircleAvatar( - backgroundColor: userInfo?.person.avatar != null - ? Colors.transparent - : theme.colorScheme.onBackground, - foregroundImage: userInfo?.person.avatar != null - ? CachedNetworkImageProvider(userInfo!.person.avatar!) - : null, + backgroundColor: userInfo?.person.avatar != null ? Colors.transparent : theme.colorScheme.onBackground, + foregroundImage: userInfo?.person.avatar != null ? CachedNetworkImageProvider(userInfo!.person.avatar!) : null, maxRadius: 45, ), const SizedBox(width: 20.0), @@ -72,11 +67,8 @@ class UserHeader extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Text( - userInfo?.person.displayName != null - ? userInfo?.person.displayName ?? '-' - : userInfo?.person.name ?? '-', - style: theme.textTheme.headlineSmall - ?.copyWith(fontWeight: FontWeight.w600), + userInfo?.person.displayName != null ? userInfo?.person.displayName ?? '-' : userInfo?.person.name ?? '-', + style: theme.textTheme.headlineSmall?.copyWith(fontWeight: FontWeight.w600), softWrap: false, maxLines: 1, overflow: TextOverflow.fade, @@ -109,13 +101,9 @@ class UserHeader extends StatelessWidget { ), ), Icon( - isSidebarOpen != null && isSidebarOpen! - ? Icons.chevron_right_rounded - : Icons.chevron_left_rounded, + isSidebarOpen != null && isSidebarOpen! ? Icons.chevron_right_rounded : Icons.chevron_left_rounded, size: 50, - shadows: [ - Shadow(color: theme.colorScheme.background, blurRadius: 5.0) - ], + shadows: [Shadow(color: theme.colorScheme.background, blurRadius: 5.0)], ), ], ), diff --git a/lib/user/widgets/user_sidebar.dart b/lib/user/widgets/user_sidebar.dart index 61c88156d..bbc8b7a85 100644 --- a/lib/user/widgets/user_sidebar.dart +++ b/lib/user/widgets/user_sidebar.dart @@ -21,7 +21,6 @@ import '../../utils/date_time.dart'; import '../bloc/user_bloc.dart'; class UserSidebar extends StatefulWidget { - final PersonViewSafe? userInfo; final List? moderates; final bool isAccountUser; @@ -41,7 +40,7 @@ class UserSidebar extends StatefulWidget { State createState() => _UserSidebarState(); } -class _UserSidebarState extends State{ +class _UserSidebarState extends State { final ScrollController _scrollController = ScrollController(); bool isBlocked = false; @@ -71,7 +70,7 @@ class _UserSidebarState extends State{ } }*/ - if( widget.blockedPerson != null ) { + if (widget.blockedPerson != null) { isBlocked = widget.blockedPerson!.blocked; } @@ -86,89 +85,108 @@ class _UserSidebarState extends State{ child: Column( children: [ Container( - child: !widget.isAccountUser ? Column( - children: [ - Padding( - padding: const EdgeInsets.only(top: 8, left: 12, right: 12,), - child: Row( + child: !widget.isAccountUser + ? Column( children: [ - Expanded( - child: ElevatedButton( - onPressed: null/*() { - HapticFeedback.mediumImpact(); - }*/, - style: TextButton.styleFrom( - fixedSize: const Size.fromHeight(40), - padding: EdgeInsets.zero, - ), - child: const Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - Icons.mail_outline_rounded, - semanticLabel: 'Message User', - ), - SizedBox(width: 4.0), - Text( - 'Message User', - ), - ], - ), + Padding( + padding: const EdgeInsets.only( + top: 8, + left: 12, + right: 12, ), - ), - const SizedBox( width: 8, height: 8,), - Expanded( - child: ElevatedButton( - onPressed: isLoggedIn ? () { - HapticFeedback.heavyImpact(); - ScaffoldMessenger.of(context).clearSnackBars(); - context.read().add( - BlockUserEvent( - personId: widget.userInfo!.person.id, - blocked: isBlocked == true ? false : true, - ), - ); - } : null, - style: TextButton.styleFrom( - fixedSize: const Size.fromHeight(40), - foregroundColor: Colors.redAccent, - padding: EdgeInsets.zero, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - isBlocked == true ? Icons.undo_rounded : Icons.block, - semanticLabel: isBlocked == true ? 'Unblock User' : 'Block User', + child: Row( + children: [ + Expanded( + child: ElevatedButton( + onPressed: null /*() { + HapticFeedback.mediumImpact(); + }*/ + , + style: TextButton.styleFrom( + fixedSize: const Size.fromHeight(40), + padding: EdgeInsets.zero, + ), + child: const Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.mail_outline_rounded, + semanticLabel: 'Message User', + ), + SizedBox(width: 4.0), + Text( + 'Message User', + ), + ], + ), ), - const SizedBox(width: 4.0), - Text( - isBlocked == true ? 'Unblock User' : 'Block User', - style: const TextStyle( - color: null, + ), + const SizedBox( + width: 8, + height: 8, + ), + Expanded( + child: ElevatedButton( + onPressed: isLoggedIn + ? () { + HapticFeedback.heavyImpact(); + ScaffoldMessenger.of(context).clearSnackBars(); + context.read().add( + BlockUserEvent( + personId: widget.userInfo!.person.id, + blocked: isBlocked == true ? false : true, + ), + ); + } + : null, + style: TextButton.styleFrom( + fixedSize: const Size.fromHeight(40), + foregroundColor: Colors.redAccent, + padding: EdgeInsets.zero, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + isBlocked == true ? Icons.undo_rounded : Icons.block, + semanticLabel: isBlocked == true ? 'Unblock User' : 'Block User', + ), + const SizedBox(width: 4.0), + Text( + isBlocked == true ? 'Unblock User' : 'Block User', + style: const TextStyle( + color: null, + ), + ), + ], ), ), - ], - ), + ), + ], ), ), + const Divider(), ], - ), - ), - const Divider(), - ], - ) : null, + ) + : null, ), Expanded( child: ListView( children: [ Padding( - padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8,), + padding: const EdgeInsets.symmetric( + horizontal: 12.0, + vertical: 8, + ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: const EdgeInsets.only(left: 8.0, right: 8, bottom: 8,), + padding: const EdgeInsets.only( + left: 8.0, + right: 8, + bottom: 8, + ), child: CommonMarkdownBody( body: widget.userInfo?.person.bio ?? 'Nothing here. This user has not written a bio.', ), @@ -181,12 +199,16 @@ class _UserSidebarState extends State{ children: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 2), - child: Icon( Icons.cake_rounded, size: 18, color: theme.colorScheme.onBackground.withOpacity(0.65),), + child: Icon( + Icons.cake_rounded, + size: 18, + color: theme.colorScheme.onBackground.withOpacity(0.65), + ), ), // TODO Make this use device date format Text( - 'Joined ${DateFormat.yMMMMd().format(widget.userInfo!.person.published)} · ${formatTimeToString(dateTime: widget.userInfo!.person.published.toIso8601String())} ago', - style: TextStyle( color: theme.colorScheme.onBackground.withOpacity(0.65)), + 'Joined ${DateFormat.yMMMMd().format(widget.userInfo!.person.published)} · ${formatTimeToString(dateTime: widget.userInfo!.person.published.toIso8601String())} ago', + style: TextStyle(color: theme.colorScheme.onBackground.withOpacity(0.65)), ), ], ), @@ -194,11 +216,15 @@ class _UserSidebarState extends State{ children: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 2), - child: Icon( Icons.wysiwyg_rounded, size: 18, color: theme.colorScheme.onBackground.withOpacity(0.65),), + child: Icon( + Icons.wysiwyg_rounded, + size: 18, + color: theme.colorScheme.onBackground.withOpacity(0.65), + ), ), Text( '${NumberFormat("#,###,###,###").format(widget.userInfo!.counts.postCount)} Posts · ${NumberFormat("#,###,###,###").format(widget.userInfo!.counts.postScore)} score', - style: TextStyle( color: theme.textTheme.titleSmall?.color?.withOpacity(0.65) ), + style: TextStyle(color: theme.textTheme.titleSmall?.color?.withOpacity(0.65)), ), ], ), @@ -206,11 +232,15 @@ class _UserSidebarState extends State{ children: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 2), - child: Icon( Icons.chat_rounded, size: 18, color: theme.colorScheme.onBackground.withOpacity(0.65),), + child: Icon( + Icons.chat_rounded, + size: 18, + color: theme.colorScheme.onBackground.withOpacity(0.65), + ), ), Text( '${NumberFormat("#,###,###,###").format(widget.userInfo!.counts.commentCount)} Comments · ${NumberFormat("#,###,###,###").format(widget.userInfo!.counts.commentScore)} score', - style: TextStyle( color: theme.textTheme.titleSmall?.color?.withOpacity(0.65) ), + style: TextStyle(color: theme.textTheme.titleSmall?.color?.withOpacity(0.65)), ), ], ), @@ -218,130 +248,137 @@ class _UserSidebarState extends State{ ), const SizedBox(height: 40.0), Container( - child: widget.moderates!.isNotEmpty ? Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text('Moderates:'), - const Divider(), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 8.0), - child: Column( - children: [ for (var mods in widget.moderates! ) - GestureDetector( - onTap: () { - account_bloc.AccountBloc accountBloc = context.read(); - AuthBloc authBloc = context.read(); - ThunderBloc thunderBloc = context.read(); + child: widget.moderates!.isNotEmpty + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text('Moderates:'), + const Divider(), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8.0), + child: Column( + children: [ + for (var mods in widget.moderates!) + GestureDetector( + onTap: () { + account_bloc.AccountBloc accountBloc = context.read(); + AuthBloc authBloc = context.read(); + ThunderBloc thunderBloc = context.read(); - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => MultiBlocProvider( - providers: [ - BlocProvider.value(value: accountBloc), - BlocProvider.value(value: authBloc), - BlocProvider.value(value: thunderBloc), - ], - child: CommunityPage(communityId: mods.community.id), - ), - ), - ); - }, - child: Padding( - padding: const EdgeInsets.only(bottom: 8.0), - child: Row( - children: [ - CircleAvatar( - backgroundColor: mods.community.icon != null ? Colors.transparent : theme.colorScheme.secondaryContainer, - foregroundImage: mods.community.icon != null ? CachedNetworkImageProvider( mods.community.icon! ) : null, - maxRadius: 20, - child: Text( - mods.community.name[0].toUpperCase() ?? '', - semanticsLabel: '', - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 16, - ), - ), - ), - const SizedBox(width: 16.0), - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - mods.community.title ?? mods.community.name ?? '', - overflow: TextOverflow.ellipsis, - maxLines: 1, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 16, + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => MultiBlocProvider( + providers: [ + BlocProvider.value(value: accountBloc), + BlocProvider.value(value: authBloc), + BlocProvider.value(value: thunderBloc), + ], + child: CommunityPage(communityId: mods.community.id), ), ), - Text( - '${mods.community.name ?? ''} · ${fetchInstanceNameFromUrl(mods.community.actorId)}', - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: theme.colorScheme.onBackground.withOpacity(0.6), - fontSize: 13, + ); + }, + child: Padding( + padding: const EdgeInsets.only(bottom: 8.0), + child: Row( + children: [ + CircleAvatar( + backgroundColor: mods.community.icon != null ? Colors.transparent : theme.colorScheme.secondaryContainer, + foregroundImage: mods.community.icon != null ? CachedNetworkImageProvider(mods.community.icon!) : null, + maxRadius: 20, + child: Text( + mods.community.name[0].toUpperCase() ?? '', + semanticsLabel: '', + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 16, + ), + ), ), - ), - ], + const SizedBox(width: 16.0), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + mods.community.title ?? mods.community.name ?? '', + overflow: TextOverflow.ellipsis, + maxLines: 1, + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 16, + ), + ), + Text( + '${mods.community.name ?? ''} · ${fetchInstanceNameFromUrl(mods.community.actorId)}', + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: theme.colorScheme.onBackground.withOpacity(0.6), + fontSize: 13, + ), + ), + ], + ), + ), + ], + ), ), ), - ], - ), + ], ), ), ], - ), - ), - ], - ) : null, + ) + : null, ), ], ), ), - const SizedBox(height: 128,) + const SizedBox( + height: 128, + ) ], ), ), - Container( - child: widget.isAccountUser ? Column( - children: [ - const Divider(), - Padding( - padding: const EdgeInsets.only(bottom: 8.0, left: 12, right: 12), - child: ElevatedButton( - onPressed: null/*() { + child: widget.isAccountUser + ? Column( + children: [ + const Divider(), + Padding( + padding: const EdgeInsets.only(bottom: 8.0, left: 12, right: 12), + child: ElevatedButton( + onPressed: null /*() { HapticFeedback.mediumImpact(); - }*/, - style: TextButton.styleFrom( - fixedSize: const Size.fromHeight(40), - foregroundColor: null, - padding: EdgeInsets.zero, - ), - child: const Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - Icons.edit, - semanticLabel: 'Edit Profile', - ), - SizedBox(width: 4.0), - Text( - 'Edit Profile', - style: TextStyle( - color: null, + }*/ + , + style: TextButton.styleFrom( + fixedSize: const Size.fromHeight(40), + foregroundColor: null, + padding: EdgeInsets.zero, + ), + child: const Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.edit, + semanticLabel: 'Edit Profile', + ), + SizedBox(width: 4.0), + Text( + 'Edit Profile', + style: TextStyle( + color: null, + ), + ), + ], ), ), - ], - ), - ), - ), - ], - ) : null, + ), + ], + ) + : null, ), ], ), @@ -350,4 +387,4 @@ class _UserSidebarState extends State{ ), ); } -} \ No newline at end of file +}