chang url container color style

This commit is contained in:
Fabian Freund
2026-05-05 10:39:58 +02:00
parent e037ca0a9b
commit 7be72795d7
2 changed files with 113 additions and 51 deletions
@@ -38,7 +38,9 @@ import 'package:weblibre/features/user/domain/repositories/general_settings.dart
import 'package:weblibre/presentation/widgets/uri_breadcrumb.dart'; import 'package:weblibre/presentation/widgets/uri_breadcrumb.dart';
class CompactAppBarTitle extends ConsumerWidget { class CompactAppBarTitle extends ConsumerWidget {
const CompactAppBarTitle({super.key}); const CompactAppBarTitle({super.key, this.containerColor});
final Color? containerColor;
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
@@ -68,6 +70,7 @@ class CompactAppBarTitle extends ConsumerWidget {
isTabTuneledAsync.hasValue && isTabTuneledAsync.value == true, isTabTuneledAsync.hasValue && isTabTuneledAsync.value == true,
siteSettingsBadgeState: siteSettingsBadgeState, siteSettingsBadgeState: siteSettingsBadgeState,
longPressUrlCopy: settings.tabBarLongPressUrlCopy, longPressUrlCopy: settings.tabBarLongPressUrlCopy,
containerColor: containerColor,
onSiteSettingsTap: () { onSiteSettingsTap: () {
ref ref
.read(bottomSheetControllerProvider.notifier) .read(bottomSheetControllerProvider.notifier)
@@ -94,6 +97,7 @@ class CompactAppBarTitleView extends StatelessWidget {
required this.onTitleTap, required this.onTitleTap,
this.tabIcon, this.tabIcon,
this.longPressUrlCopy = true, this.longPressUrlCopy = true,
this.containerColor,
}); });
final TabState tabState; final TabState tabState;
@@ -103,11 +107,13 @@ class CompactAppBarTitleView extends StatelessWidget {
final VoidCallback onTitleTap; final VoidCallback onTitleTap;
final Widget? tabIcon; final Widget? tabIcon;
final bool longPressUrlCopy; final bool longPressUrlCopy;
final Color? containerColor;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Theme.of(context); final theme = Theme.of(context);
final appColors = AppColors.of(context); final appColors = AppColors.of(context);
final containerColor = this.containerColor;
return Row( return Row(
children: [ children: [
@@ -142,11 +148,24 @@ class CompactAppBarTitleView extends StatelessWidget {
Expanded( Expanded(
child: GestureDetector( child: GestureDetector(
onTap: onTitleTap, onTap: onTitleTap,
child: Container( child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
curve: Curves.easeInOut,
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 12), padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 12),
decoration: BoxDecoration( decoration: BoxDecoration(
color: theme.colorScheme.surfaceContainerHighest, color: containerColor != null
? Color.alphaBlend(
containerColor.withValues(alpha: 0.08),
theme.colorScheme.surfaceContainerHighest,
)
: theme.colorScheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(24), borderRadius: BorderRadius.circular(24),
border: containerColor != null
? Border.all(
color: containerColor.withValues(alpha: 0.5),
width: 2,
)
: null,
), ),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@@ -171,7 +190,11 @@ class CompactAppBarTitleView extends StatelessWidget {
const Icon(MdiIcons.tunnelOutline, size: 16), const Icon(MdiIcons.tunnelOutline, size: 16),
const SizedBox(width: 4), const SizedBox(width: 4),
], ],
_SecurityStatusIcon(tabState: tabState, size: 16), _SecurityStatusIcon(
tabState: tabState,
size: 16,
containerColor: containerColor,
),
const SizedBox(width: 6), const SizedBox(width: 6),
Flexible( Flexible(
child: UriBreadcrumb( child: UriBreadcrumb(
@@ -201,7 +224,9 @@ class CompactAppBarTitleView extends StatelessWidget {
} }
class AppBarTitle extends ConsumerWidget { class AppBarTitle extends ConsumerWidget {
const AppBarTitle({super.key}); const AppBarTitle({super.key, this.containerColor});
final Color? containerColor;
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
@@ -231,6 +256,7 @@ class AppBarTitle extends ConsumerWidget {
isTabTuneledAsync.hasValue && isTabTuneledAsync.value == true, isTabTuneledAsync.hasValue && isTabTuneledAsync.value == true,
siteSettingsBadgeState: siteSettingsBadgeState, siteSettingsBadgeState: siteSettingsBadgeState,
longPressUrlCopy: settings.tabBarLongPressUrlCopy, longPressUrlCopy: settings.tabBarLongPressUrlCopy,
containerColor: containerColor,
onSiteSettingsTap: () { onSiteSettingsTap: () {
ref ref
.read(bottomSheetControllerProvider.notifier) .read(bottomSheetControllerProvider.notifier)
@@ -257,6 +283,7 @@ class AppBarTitleView extends StatelessWidget {
required this.onTitleTap, required this.onTitleTap,
required this.longPressUrlCopy, required this.longPressUrlCopy,
this.tabIcon, this.tabIcon,
this.containerColor,
}); });
final TabState tabState; final TabState tabState;
@@ -266,11 +293,13 @@ class AppBarTitleView extends StatelessWidget {
final VoidCallback onTitleTap; final VoidCallback onTitleTap;
final Widget? tabIcon; final Widget? tabIcon;
final bool longPressUrlCopy; final bool longPressUrlCopy;
final Color? containerColor;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Theme.of(context); final theme = Theme.of(context);
final appColors = AppColors.of(context); final appColors = AppColors.of(context);
final containerColor = this.containerColor;
return Row( return Row(
children: [ children: [
@@ -333,7 +362,28 @@ class AppBarTitleView extends StatelessWidget {
), ),
), ),
), ),
Row( AnimatedContainer(
duration: const Duration(milliseconds: 200),
curve: Curves.easeInOut,
padding: containerColor != null
? const EdgeInsets.symmetric(vertical: 2, horizontal: 8)
: EdgeInsets.zero,
decoration: BoxDecoration(
color: containerColor != null
? Color.alphaBlend(
containerColor.withValues(alpha: 0.08),
theme.colorScheme.surfaceContainerHighest,
)
: null,
borderRadius: BorderRadius.circular(12),
border: containerColor != null
? Border.all(
color: containerColor.withValues(alpha: 0.5),
width: 2,
)
: null,
),
child: Row(
children: [ children: [
if (tabState.tabMode is PrivateTabMode) ...[ if (tabState.tabMode is PrivateTabMode) ...[
Icon( Icon(
@@ -354,7 +404,11 @@ class AppBarTitleView extends StatelessWidget {
const Icon(MdiIcons.tunnelOutline, size: 14), const Icon(MdiIcons.tunnelOutline, size: 14),
const SizedBox(width: 4), const SizedBox(width: 4),
], ],
_SecurityStatusIcon(tabState: tabState, size: 14), _SecurityStatusIcon(
tabState: tabState,
size: 14,
containerColor: containerColor,
),
const SizedBox(width: 4), const SizedBox(width: 4),
Expanded( Expanded(
child: UriBreadcrumb( child: UriBreadcrumb(
@@ -365,7 +419,9 @@ class AppBarTitleView extends StatelessWidget {
onTooltipTriggered: longPressUrlCopy onTooltipTriggered: longPressUrlCopy
? () async { ? () async {
await Clipboard.setData( await Clipboard.setData(
ClipboardData(text: tabState.url.toString()), ClipboardData(
text: tabState.url.toString(),
),
); );
} }
: null, : null,
@@ -373,6 +429,7 @@ class AppBarTitleView extends StatelessWidget {
), ),
], ],
), ),
),
], ],
), ),
), ),
@@ -384,10 +441,15 @@ class AppBarTitleView extends StatelessWidget {
} }
class _SecurityStatusIcon extends StatelessWidget { class _SecurityStatusIcon extends StatelessWidget {
const _SecurityStatusIcon({required this.tabState, required this.size}); const _SecurityStatusIcon({
required this.tabState,
required this.size,
this.containerColor,
});
final TabState tabState; final TabState tabState;
final double size; final double size;
final Color? containerColor;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -398,7 +460,7 @@ class _SecurityStatusIcon extends StatelessWidget {
size: size, size: size,
); );
} else if (tabState.readerableState.active) { } else if (tabState.readerableState.active) {
return Icon(MdiIcons.lockMinus, size: size); return Icon(MdiIcons.lockMinus, color: containerColor, size: size);
} else if (!tabState.securityInfoState.secure) { } else if (!tabState.securityInfoState.secure) {
return Icon( return Icon(
MdiIcons.lockAlert, MdiIcons.lockAlert,
@@ -406,10 +468,10 @@ class _SecurityStatusIcon extends StatelessWidget {
size: size, size: size,
); );
} else if (!tabState.isLoading) { } else if (!tabState.isLoading) {
return Icon(MdiIcons.lock, size: size); return Icon(MdiIcons.lock, color: containerColor, size: size);
} }
return Icon(MdiIcons.timerSand, size: size); return Icon(MdiIcons.timerSand, color: containerColor, size: size);
} }
} }
@@ -234,11 +234,11 @@ class BrowserTabBar extends HookConsumerWidget {
final showTabTitle = displayedSheet is! ViewTabsSheet; final showTabTitle = displayedSheet is! ViewTabsSheet;
final backgroundColor = final effectiveContainerColor =
(settings.showContainerUi && (settings.showContainerUi &&
containerColor != null && containerColor != null &&
displayedSheet is! ViewTabsSheet) displayedSheet is! ViewTabsSheet)
? ContainerColors.forAppBar(containerColor) ? containerColor
: null; : null;
return BrowserTabBarView( return BrowserTabBarView(
@@ -247,11 +247,11 @@ class BrowserTabBar extends HookConsumerWidget {
showQuickTabSwitcherBar: showQuickTabSwitcherBar, showQuickTabSwitcherBar: showQuickTabSwitcherBar,
displayAppBar: displayAppBar, displayAppBar: displayAppBar,
displayQuickTabSwitcher: displayQuickTabSwitcher, displayQuickTabSwitcher: displayQuickTabSwitcher,
backgroundColor: backgroundColor, backgroundColor: null,
title: showTabTitle title: showTabTitle
? settings.tabBarLayout == TabBarLayout.compact ? settings.tabBarLayout == TabBarLayout.compact
? const CompactAppBarTitle() ? CompactAppBarTitle(containerColor: effectiveContainerColor)
: const AppBarTitle() : AppBarTitle(containerColor: effectiveContainerColor)
: null, : null,
actions: [ actions: [
const PinnedAddonBar(), const PinnedAddonBar(),