extract getEffectiveCenterTitle
This commit is contained in:
@@ -112,7 +112,11 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final effectiveCenterTitle = _getEffectiveCenterTitle(Theme.of(context));
|
final effectiveCenterTitle = getEffectiveCenterTitle(
|
||||||
|
Theme.of(context),
|
||||||
|
actions: actions,
|
||||||
|
centerTitle: centerTitle,
|
||||||
|
);
|
||||||
final channel = StreamChannel.of(context).channel;
|
final channel = StreamChannel.of(context).channel;
|
||||||
final channelHeaderTheme = ChannelHeaderTheme.of(context);
|
final channelHeaderTheme = ChannelHeaderTheme.of(context);
|
||||||
|
|
||||||
@@ -205,21 +209,4 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
final Size preferredSize;
|
final Size preferredSize;
|
||||||
|
|
||||||
bool _getEffectiveCenterTitle(ThemeData theme) {
|
|
||||||
if (centerTitle != null) return centerTitle!;
|
|
||||||
if (theme.appBarTheme.centerTitle != null) {
|
|
||||||
return theme.appBarTheme.centerTitle!;
|
|
||||||
}
|
|
||||||
switch (theme.platform) {
|
|
||||||
case TargetPlatform.android:
|
|
||||||
case TargetPlatform.fuchsia:
|
|
||||||
case TargetPlatform.linux:
|
|
||||||
case TargetPlatform.windows:
|
|
||||||
return false;
|
|
||||||
case TargetPlatform.iOS:
|
|
||||||
case TargetPlatform.macOS:
|
|
||||||
return actions == null || actions!.length < 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,12 @@ class ThreadHeader extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final effectiveCenterTitle = _getEffectiveCenterTitle(Theme.of(context));
|
final effectiveCenterTitle = getEffectiveCenterTitle(
|
||||||
|
Theme.of(context),
|
||||||
|
actions: actions,
|
||||||
|
centerTitle: centerTitle,
|
||||||
|
);
|
||||||
|
|
||||||
final channelHeaderTheme = ChannelHeaderTheme.of(context);
|
final channelHeaderTheme = ChannelHeaderTheme.of(context);
|
||||||
|
|
||||||
final defaultSubtitle = subtitle ??
|
final defaultSubtitle = subtitle ??
|
||||||
@@ -191,21 +196,4 @@ class ThreadHeader extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
final Size preferredSize;
|
final Size preferredSize;
|
||||||
|
|
||||||
bool _getEffectiveCenterTitle(ThemeData theme) {
|
|
||||||
if (centerTitle != null) return centerTitle!;
|
|
||||||
if (theme.appBarTheme.centerTitle != null) {
|
|
||||||
return theme.appBarTheme.centerTitle!;
|
|
||||||
}
|
|
||||||
switch (theme.platform) {
|
|
||||||
case TargetPlatform.android:
|
|
||||||
case TargetPlatform.fuchsia:
|
|
||||||
case TargetPlatform.linux:
|
|
||||||
case TargetPlatform.windows:
|
|
||||||
return false;
|
|
||||||
case TargetPlatform.iOS:
|
|
||||||
case TargetPlatform.macOS:
|
|
||||||
return actions == null || actions!.length < 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,28 @@ Future<void> launchURL(BuildContext context, String url) async {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get centerTitle considering a default and platform specific behaviour
|
||||||
|
bool getEffectiveCenterTitle(
|
||||||
|
ThemeData theme, {
|
||||||
|
bool? centerTitle,
|
||||||
|
List<Widget>? actions,
|
||||||
|
}) {
|
||||||
|
if (centerTitle != null) return centerTitle;
|
||||||
|
if (theme.appBarTheme.centerTitle != null) {
|
||||||
|
return theme.appBarTheme.centerTitle!;
|
||||||
|
}
|
||||||
|
switch (theme.platform) {
|
||||||
|
case TargetPlatform.android:
|
||||||
|
case TargetPlatform.fuchsia:
|
||||||
|
case TargetPlatform.linux:
|
||||||
|
case TargetPlatform.windows:
|
||||||
|
return false;
|
||||||
|
case TargetPlatform.iOS:
|
||||||
|
case TargetPlatform.macOS:
|
||||||
|
return actions == null || actions.length < 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Shows confirmation dialog
|
/// Shows confirmation dialog
|
||||||
Future<bool?> showConfirmationDialog(
|
Future<bool?> showConfirmationDialog(
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
|
|||||||
Reference in New Issue
Block a user