Refactor button overlay color handling in document viewer, file explorer, and home page for improved state management

This commit is contained in:
Leon Bösche
2026-01-16 14:43:29 +01:00
parent c2db24133b
commit b006187320
3 changed files with 147 additions and 18 deletions

View File

@@ -562,9 +562,14 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
TextButton(
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
overlayColor: WidgetStateProperty.all(
Colors.transparent,
),
overlayColor: WidgetStateProperty.resolveWith<Color?>((
Set<WidgetState> states,
) {
if (states.contains(WidgetState.pressed)) {
return Colors.transparent;
}
return null; // Use default for other states (like hover)
}),
),
onPressed: () => Navigator.of(context).pop(false),
child: const Text(
@@ -575,9 +580,14 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
TextButton(
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
overlayColor: WidgetStateProperty.all(
Colors.transparent,
),
overlayColor: WidgetStateProperty.resolveWith<Color?>((
Set<WidgetState> states,
) {
if (states.contains(WidgetState.pressed)) {
return Colors.transparent;
}
return null; // Use default for other states (like hover)
}),
),
onPressed: () => Navigator.of(context).pop(true),
child: const Text(
@@ -1010,9 +1020,14 @@ class _DocumentViewerState extends State<DocumentViewer> {
TextButton(
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
overlayColor: WidgetStateProperty.all(
Colors.transparent,
),
overlayColor: WidgetStateProperty.resolveWith<Color?>((
Set<WidgetState> states,
) {
if (states.contains(WidgetState.pressed)) {
return Colors.transparent;
}
return null; // Use default for other states (like hover)
}),
),
onPressed: () => Navigator.of(context).pop(false),
child: const Text(
@@ -1023,9 +1038,14 @@ class _DocumentViewerState extends State<DocumentViewer> {
TextButton(
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
overlayColor: WidgetStateProperty.all(
Colors.transparent,
),
overlayColor: WidgetStateProperty.resolveWith<Color?>((
Set<WidgetState> states,
) {
if (states.contains(WidgetState.pressed)) {
return Colors.transparent;
}
return null; // Use default for other states (like hover)
}),
),
onPressed: () => Navigator.of(context).pop(true),
child: const Text(

View File

@@ -224,6 +224,14 @@ class _FileExplorerState extends State<FileExplorer> {
TextButton(
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
overlayColor: WidgetStateProperty.resolveWith<Color?>((
Set<WidgetState> states,
) {
if (states.contains(WidgetState.pressed)) {
return Colors.transparent;
}
return null; // Use default for other states (like hover)
}),
),
onPressed: () => Navigator.of(context).pop(),
child: const Text(
@@ -234,6 +242,14 @@ class _FileExplorerState extends State<FileExplorer> {
TextButton(
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
overlayColor: WidgetStateProperty.resolveWith<Color?>((
Set<WidgetState> states,
) {
if (states.contains(WidgetState.pressed)) {
return Colors.transparent;
}
return null; // Use default for other states (like hover)
}),
),
onPressed: () {
final folderName = controller.text.trim();
@@ -337,6 +353,14 @@ class _FileExplorerState extends State<FileExplorer> {
TextButton(
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
overlayColor: WidgetStateProperty.resolveWith<Color?>((
Set<WidgetState> states,
) {
if (states.contains(WidgetState.pressed)) {
return Colors.transparent;
}
return null; // Use default for other states (like hover)
}),
),
onPressed: () => Navigator.of(context).pop(),
child: const Text(
@@ -347,6 +371,14 @@ class _FileExplorerState extends State<FileExplorer> {
TextButton(
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
overlayColor: WidgetStateProperty.resolveWith<Color?>((
Set<WidgetState> states,
) {
if (states.contains(WidgetState.pressed)) {
return Colors.transparent;
}
return null; // Use default for other states (like hover)
}),
),
onPressed: () {
final docName = controller.text.trim();
@@ -535,6 +567,14 @@ class _FileExplorerState extends State<FileExplorer> {
TextButton(
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
overlayColor: WidgetStateProperty.resolveWith<Color?>((
Set<WidgetState> states,
) {
if (states.contains(WidgetState.pressed)) {
return Colors.transparent;
}
return null; // Use default for other states (like hover)
}),
),
onPressed: () => Navigator.of(context).pop(),
child: const Text(
@@ -545,6 +585,14 @@ class _FileExplorerState extends State<FileExplorer> {
TextButton(
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
overlayColor: WidgetStateProperty.resolveWith<Color?>((
Set<WidgetState> states,
) {
if (states.contains(WidgetState.pressed)) {
return Colors.transparent;
}
return null; // Use default for other states (like hover)
}),
),
onPressed: () {
final newName = controller.text.trim();
@@ -759,6 +807,14 @@ class _FileExplorerState extends State<FileExplorer> {
TextButton(
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
overlayColor: WidgetStateProperty.resolveWith<Color?>((
Set<WidgetState> states,
) {
if (states.contains(WidgetState.pressed)) {
return Colors.transparent;
}
return null; // Use default for other states (like hover)
}),
),
onPressed: () => Navigator.of(context).pop(false),
child: const Text(
@@ -769,6 +825,14 @@ class _FileExplorerState extends State<FileExplorer> {
TextButton(
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
overlayColor: WidgetStateProperty.resolveWith<Color?>((
Set<WidgetState> states,
) {
if (states.contains(WidgetState.pressed)) {
return Colors.transparent;
}
return null; // Use default for other states (like hover)
}),
),
onPressed: () => Navigator.of(context).pop(true),
child: const Text(
@@ -1428,10 +1492,25 @@ class _FileExplorerState extends State<FileExplorer> {
child: Row(
children: state.breadcrumbs.map((breadcrumb) {
return TextButton(
style: TextButton.styleFrom(
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
padding: EdgeInsets.zero,
minimumSize: Size.zero,
overlayColor:
WidgetStateProperty.resolveWith<
Color?
>((Set<WidgetState> states) {
if (states.contains(
WidgetState.pressed,
)) {
return Colors.transparent;
}
return null; // Use default for other states (like hover)
}),
padding: WidgetStateProperty.all(
EdgeInsets.zero,
),
minimumSize: WidgetStateProperty.all(
Size.zero,
),
tapTargetSize:
MaterialTapTargetSize.shrinkWrap,
),

View File

@@ -238,7 +238,17 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
final highlightColor = const Color.fromARGB(255, 100, 200, 255);
final defaultColor = AppTheme.secondaryText;
return TextButton(
style: ButtonStyle(splashFactory: NoSplash.splashFactory),
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
overlayColor: WidgetStateProperty.resolveWith<Color?>((
Set<WidgetState> states,
) {
if (states.contains(WidgetState.pressed)) {
return Colors.transparent;
}
return null; // Use default for other states (like hover)
}),
),
onPressed: onTap,
child: Text(
org.name,
@@ -254,7 +264,17 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
final highlightColor = const Color.fromARGB(255, 100, 200, 255);
final defaultColor = AppTheme.secondaryText;
return TextButton(
style: ButtonStyle(splashFactory: NoSplash.splashFactory),
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
overlayColor: WidgetStateProperty.resolveWith<Color?>((
Set<WidgetState> states,
) {
if (states.contains(WidgetState.pressed)) {
return Colors.transparent;
}
return null; // Use default for other states (like hover)
}),
),
onPressed: onTap,
child: Text(
'Personal',
@@ -269,7 +289,17 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
Widget _buildAddButton(VoidCallback onTap) {
final defaultColor = AppTheme.secondaryText;
return TextButton(
style: ButtonStyle(splashFactory: NoSplash.splashFactory),
style: ButtonStyle(
splashFactory: NoSplash.splashFactory,
overlayColor: WidgetStateProperty.resolveWith<Color?>((
Set<WidgetState> states,
) {
if (states.contains(WidgetState.pressed)) {
return Colors.transparent;
}
return null; // Use default for other states (like hover)
}),
),
onPressed: onTap,
child: Text('+ Add Organization', style: TextStyle(color: defaultColor)),
);