Skip to content

Commit

Permalink
Pass a correct subtitle Widget
Browse files Browse the repository at this point in the history
  • Loading branch information
g123k committed Jul 22, 2023
1 parent ec84423 commit 2af2475
Showing 1 changed file with 24 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:async';

import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:iso_countries/iso_countries.dart';
Expand Down Expand Up @@ -208,17 +207,13 @@ class _ProductQueryPageState extends State<ProductQueryPage>
automaticallyImplyLeading: false,
leading: const SmoothBackButton(),
title: _AppBarTitle(
name: widget.searchResult
title: widget.searchResult
? widget.name
: appLocalizations.product_search_same_category,
editableAppBarTitle: widget.editableAppBarTitle,
editableAppBarTitle:
widget.searchResult && widget.editableAppBarTitle,
),
subTitle: !widget.searchResult
? _AppBarTitle(
name: widget.name,
editableAppBarTitle: widget.editableAppBarTitle,
)
: null,
subTitle: !widget.searchResult ? Text(widget.name) : null,
actions: _getAppBarButtons(),
),
body: RefreshIndicator(
Expand Down Expand Up @@ -504,7 +499,7 @@ class _EmptyScreen extends StatelessWidget {
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
leading: const SmoothBackButton(),
title: _AppBarTitle(
name: name,
title: name,
editableAppBarTitle: false,
),
actions: actions,
Expand All @@ -516,31 +511,38 @@ class _EmptyScreen extends StatelessWidget {

class _AppBarTitle extends StatelessWidget {
const _AppBarTitle({
required this.name,
required this.title,
this.multiLines = true,
required this.editableAppBarTitle,
Key? key,
}) : super(key: key);

final String name;
final String title;
final bool multiLines;
final bool editableAppBarTitle;

@override
Widget build(BuildContext context) {
final Widget child = AutoSizeText(
name,
maxLines: 2,
final Widget child = Text(
title,
maxLines: multiLines ? 2 : 1,
);

if (editableAppBarTitle) {
final AppLocalizations appLocalizations = AppLocalizations.of(context);

return GestureDetector(
onTap: () {
Navigator.of(context).pop(ProductQueryPageResult.editProductQuery);
},
child: Tooltip(
message: appLocalizations.tap_to_edit_search,
return InkWell(
onTap: () {
Navigator.of(context).pop(ProductQueryPageResult.editProductQuery);
},
child: Tooltip(
message: appLocalizations.tap_to_edit_search,
child: SizedBox(
width: double.infinity,
child: child,
));
),
),
);
} else {
return child;
}
Expand Down

0 comments on commit 2af2475

Please sign in to comment.