From c70edb957d03875483d7bd75efe9653c997c0b10 Mon Sep 17 00:00:00 2001 From: Aliaksei Tratseuski Date: Wed, 15 May 2024 20:20:59 +0400 Subject: [PATCH] fix: center empty_page_placeholder title alignment --- lib/ui/helpers/empty_page_placeholder.dart | 57 +++++++++++++++------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/lib/ui/helpers/empty_page_placeholder.dart b/lib/ui/helpers/empty_page_placeholder.dart index e96f91f9..5abc8434 100644 --- a/lib/ui/helpers/empty_page_placeholder.dart +++ b/lib/ui/helpers/empty_page_placeholder.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:gap/gap.dart'; import 'package:selfprivacy/ui/components/not_ready_card/not_ready_card.dart'; class EmptyPagePlaceholder extends StatelessWidget { @@ -10,50 +11,72 @@ class EmptyPagePlaceholder extends StatelessWidget { super.key, }); + final bool showReadyCard; + final IconData iconData; final String title; final String description; - final IconData iconData; - final bool showReadyCard; @override - Widget build(final BuildContext context) => !showReadyCard - ? _expandedContent(context) - : Column( + Widget build(final BuildContext context) => showReadyCard + ? Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - const Padding( - padding: EdgeInsets.symmetric(horizontal: 15), - child: NotReadyCard(), - ), - Expanded( - child: Container( - padding: const EdgeInsets.symmetric(horizontal: 15), - child: Center( - child: _expandedContent(context), + if (showReadyCard) + const Padding( + padding: EdgeInsets.symmetric( + vertical: 15, + horizontal: 15, ), + child: NotReadyCard(), + ), + Expanded( + child: _ContentWidget( + iconData: iconData, + title: title, + description: description, ), ), ], + ) + : _ContentWidget( + iconData: iconData, + title: title, + description: description, ); +} - Widget _expandedContent(final BuildContext context) => Padding( +class _ContentWidget extends StatelessWidget { + const _ContentWidget({ + required this.iconData, + required this.title, + required this.description, + }); + + final IconData iconData; + final String title; + final String description; + + @override + Widget build(final BuildContext context) => Container( padding: const EdgeInsets.symmetric(horizontal: 20), child: Column( mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, children: [ Icon( iconData, size: 50, color: Theme.of(context).colorScheme.onBackground, ), - const SizedBox(height: 16), + const Gap(16), Text( title, style: Theme.of(context).textTheme.headlineMedium?.copyWith( color: Theme.of(context).colorScheme.onBackground, ), + textAlign: TextAlign.center, ), - const SizedBox(height: 8), + const Gap(8), Text( description, textAlign: TextAlign.center,