Skip to content

Commit

Permalink
feat(app): fix title size and spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Sep 6, 2024
1 parent 2339939 commit 8d11c90
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 26 deletions.
14 changes: 11 additions & 3 deletions app/lib/common/widgets/page_scaffold.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import '../../drug/widgets/tooltip_icon.dart';
import '../module.dart';

double? _getTitleSpacing({required bool backButtonPresent}) {
return backButtonPresent ? 0 : null;
}

EdgeInsets pagePadding() => EdgeInsets.only(
left: PharMeTheme.defaultPagePadding,
right: PharMeTheme.defaultPagePadding,
Expand All @@ -12,7 +16,7 @@ Widget buildTitle(String text, { String? tooltipText }) {
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(text, style: PharMeTheme.textTheme.headlineLarge),
Text(text, style: PharMeTheme.textTheme.headlineMedium),
if (tooltipText.isNotNullOrBlank) Padding(
padding: EdgeInsets.only(left: PharMeTheme.smallSpace),
child: TooltipIcon(
Expand All @@ -30,6 +34,7 @@ Scaffold pageScaffold({
required List<Widget> body,
List<Widget>? actions,
Key? key,
bool canNavigateBack = true,
}) {
return Scaffold(
key: key,
Expand All @@ -40,12 +45,14 @@ Scaffold pageScaffold({
foregroundColor: PharMeTheme.appBarTheme.foregroundColor,
elevation: PharMeTheme.appBarTheme.elevation,
leadingWidth: PharMeTheme.appBarTheme.leadingWidth,
automaticallyImplyLeading: canNavigateBack,
floating: true,
pinned: true,
snap: false,
centerTitle: PharMeTheme.appBarTheme.centerTitle,
title: buildTitle(title),
actions: actions,
titleSpacing: _getTitleSpacing(backButtonPresent: canNavigateBack),
),
SliverPadding(
padding: pagePadding(),
Expand All @@ -61,7 +68,7 @@ Scaffold unscrollablePageScaffold({
String? titleTooltip,
List<Widget>? actions,
Widget? drawer,
bool automaticallyImplyLeading = true,
bool canNavigateBack = true,
Key? key,
}) {
final appBar = title == null
Expand All @@ -71,11 +78,12 @@ Scaffold unscrollablePageScaffold({
foregroundColor: PharMeTheme.appBarTheme.foregroundColor,
elevation: PharMeTheme.appBarTheme.elevation,
leadingWidth: PharMeTheme.appBarTheme.leadingWidth,
automaticallyImplyLeading: automaticallyImplyLeading,
automaticallyImplyLeading: canNavigateBack,
centerTitle: PharMeTheme.appBarTheme.centerTitle,
title: buildTitle(title, tooltipText: titleTooltip),
actions: actions,
scrolledUnderElevation: 0,
titleSpacing: _getTitleSpacing(backButtonPresent: canNavigateBack),
);
return Scaffold(
key: key,
Expand Down
1 change: 1 addition & 0 deletions app/lib/drug_selection/pages/drug_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class DrugSelectionPage extends HookWidget {
}
return unscrollablePageScaffold(
title: context.l10n.drug_selection_header,
canNavigateBack: !concludesOnboarding,
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expand Down
47 changes: 25 additions & 22 deletions app/lib/faq/pages/faq.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,31 @@ class FaqPage extends StatelessWidget {
Widget build(BuildContext context) {
return PopScope(
canPop: false,
child: pageScaffold(title: context.l10n.tab_faq, body: [
Padding(
padding: const EdgeInsets.all(PharMeTheme.smallSpace),
child: Column(
key: Key('questionsColumn'),
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 8),
...faqContent.flatMap((faqSection) =>
_buildTopic(context, faqSection)),
..._buildTopicHeader(
context.l10n.more_page_contact_us,
addSpace: true,
),
_buildQuestionCard(
child: ListTile(
title: Text(context.l10n.faq_contact_us),
trailing: Icon(Icons.chevron_right_rounded),
iconColor: PharMeTheme.iconColor,
onTap: () => sendEmail(context),
)
),
child: pageScaffold(
title: context.l10n.tab_faq,
canNavigateBack: false,
body: [
Padding(
padding: const EdgeInsets.all(PharMeTheme.smallSpace),
child: Column(
key: Key('questionsColumn'),
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 8),
...faqContent.flatMap((faqSection) =>
_buildTopic(context, faqSection)),
..._buildTopicHeader(
context.l10n.more_page_contact_us,
addSpace: true,
),
_buildQuestionCard(
child: ListTile(
title: Text(context.l10n.faq_contact_us),
trailing: Icon(Icons.chevron_right_rounded),
iconColor: PharMeTheme.iconColor,
onTap: () => sendEmail(context),
)
),
],
),
),
Expand Down
1 change: 1 addition & 0 deletions app/lib/more/pages/more.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class MorePage extends StatelessWidget {
canPop: false,
child: pageScaffold(
title: context.l10n.tab_more,
canNavigateBack: false,
body: [
SubheaderDivider(
text: context.l10n.more_page_account_settings,
Expand Down
1 change: 1 addition & 0 deletions app/lib/report/pages/report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class ReportPage extends StatelessWidget {
canPop: false,
child: unscrollablePageScaffold(
title: context.l10n.tab_report,
canNavigateBack: false,
titleTooltip: context.l10n.report_page_faq_tooltip,
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down
2 changes: 1 addition & 1 deletion app/lib/search/pages/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class SearchPage extends HookWidget {
canPop: false,
child: unscrollablePageScaffold(
title: context.l10n.tab_drugs,
canNavigateBack: false,
body: DrugSearch(
key: Key('drug-search'),
showFilter: true,
Expand All @@ -39,7 +40,6 @@ class SearchPage extends HookWidget {
activeDrugs,
useDrugClass: useDrugClass,
),
automaticallyImplyLeading: false, // do not show leading "menu" icon
),
),
);
Expand Down

0 comments on commit 8d11c90

Please sign in to comment.