more message view stuff

This commit is contained in:
2024-06-08 20:01:23 +02:00
parent b00ba83370
commit 64709920f7
12 changed files with 205 additions and 69 deletions

View File

@@ -11,46 +11,64 @@ class SCNAppBar extends StatelessWidget implements PreferredSizeWidget {
required this.showThemeSwitch,
required this.showDebug,
required this.showSearch,
required this.showShare,
this.onShare = null,
}) : super(key: key);
final String? title;
final bool showThemeSwitch;
final bool showDebug;
final bool showSearch;
final bool showShare;
final void Function()? onShare;
@override
Widget build(BuildContext context) {
var actions = <Widget>[];
if (showThemeSwitch) {
actions.add(Consumer<AppTheme>(
builder: (context, appTheme, child) => IconButton(
icon: Icon(appTheme.darkMode ? FontAwesomeIcons.solidSun : FontAwesomeIcons.solidMoon),
tooltip: appTheme.darkMode ? 'Light mode' : 'Dark mode',
onPressed: appTheme.switchDarkMode,
),
));
} else {
actions.add(SizedBox.square(dimension: 40));
}
if (showDebug) {
actions.add(IconButton(
icon: const Icon(FontAwesomeIcons.solidSpiderBlackWidow),
tooltip: 'Debug',
onPressed: () {
Navigator.push(context, MaterialPageRoute<DebugMainPage>(builder: (context) => DebugMainPage()));
},
));
} else {
actions.add(SizedBox.square(dimension: 40));
}
if (showSearch) {
actions.add(IconButton(
icon: const Icon(FontAwesomeIcons.solidMagnifyingGlass),
tooltip: 'Search',
onPressed: () {/*TODO*/},
));
} else if (showShare) {
actions.add(IconButton(
icon: const Icon(FontAwesomeIcons.solidShareNodes),
tooltip: 'Share',
onPressed: onShare ?? () {},
));
} else {
actions.add(SizedBox.square(dimension: 40));
}
return AppBar(
title: Text(title ?? 'Simple Cloud Notifier 2.0'),
actions: <Widget>[
if (showThemeSwitch)
Consumer<AppTheme>(
builder: (context, appTheme, child) => IconButton(
icon: Icon(appTheme.darkMode ? FontAwesomeIcons.solidSun : FontAwesomeIcons.solidMoon),
tooltip: 'Debug',
onPressed: () {
appTheme.switchDarkMode();
},
),
),
if (!showThemeSwitch) SizedBox.square(dimension: 40),
if (showDebug)
IconButton(
icon: const Icon(FontAwesomeIcons.solidSpiderBlackWidow),
tooltip: 'Debug',
onPressed: () {
Navigator.push(context, MaterialPageRoute<DebugMainPage>(builder: (context) => DebugMainPage()));
},
),
if (!showDebug) SizedBox.square(dimension: 40),
if (showSearch)
IconButton(
icon: const Icon(FontAwesomeIcons.solidMagnifyingGlass),
tooltip: 'Search',
onPressed: () {},
),
if (!showSearch) SizedBox.square(dimension: 40),
],
actions: actions,
backgroundColor: Theme.of(context).secondaryHeaderColor,
);
}

View File

@@ -9,6 +9,8 @@ class SCNScaffold extends StatelessWidget {
this.showThemeSwitch = true,
this.showDebug = true,
this.showSearch = true,
this.showShare = false,
this.onShare = null,
}) : super(key: key);
final Widget child;
@@ -16,6 +18,8 @@ class SCNScaffold extends StatelessWidget {
final bool showThemeSwitch;
final bool showDebug;
final bool showSearch;
final bool showShare;
final void Function()? onShare;
@override
Widget build(BuildContext context) {
@@ -25,6 +29,8 @@ class SCNScaffold extends StatelessWidget {
showThemeSwitch: showThemeSwitch,
showDebug: showDebug,
showSearch: showSearch,
showShare: showShare,
onShare: onShare ?? () {},
),
body: child,
);