Refactor button overlay color handling in document viewer, file explorer, and home page for improved state management
This commit is contained in:
@@ -562,9 +562,14 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
|
|||||||
TextButton(
|
TextButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
splashFactory: NoSplash.splashFactory,
|
splashFactory: NoSplash.splashFactory,
|
||||||
overlayColor: WidgetStateProperty.all(
|
overlayColor: WidgetStateProperty.resolveWith<Color?>((
|
||||||
Colors.transparent,
|
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),
|
onPressed: () => Navigator.of(context).pop(false),
|
||||||
child: const Text(
|
child: const Text(
|
||||||
@@ -575,9 +580,14 @@ class _DocumentViewerModalState extends State<DocumentViewerModal> {
|
|||||||
TextButton(
|
TextButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
splashFactory: NoSplash.splashFactory,
|
splashFactory: NoSplash.splashFactory,
|
||||||
overlayColor: WidgetStateProperty.all(
|
overlayColor: WidgetStateProperty.resolveWith<Color?>((
|
||||||
Colors.transparent,
|
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),
|
onPressed: () => Navigator.of(context).pop(true),
|
||||||
child: const Text(
|
child: const Text(
|
||||||
@@ -1010,9 +1020,14 @@ class _DocumentViewerState extends State<DocumentViewer> {
|
|||||||
TextButton(
|
TextButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
splashFactory: NoSplash.splashFactory,
|
splashFactory: NoSplash.splashFactory,
|
||||||
overlayColor: WidgetStateProperty.all(
|
overlayColor: WidgetStateProperty.resolveWith<Color?>((
|
||||||
Colors.transparent,
|
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),
|
onPressed: () => Navigator.of(context).pop(false),
|
||||||
child: const Text(
|
child: const Text(
|
||||||
@@ -1023,9 +1038,14 @@ class _DocumentViewerState extends State<DocumentViewer> {
|
|||||||
TextButton(
|
TextButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
splashFactory: NoSplash.splashFactory,
|
splashFactory: NoSplash.splashFactory,
|
||||||
overlayColor: WidgetStateProperty.all(
|
overlayColor: WidgetStateProperty.resolveWith<Color?>((
|
||||||
Colors.transparent,
|
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),
|
onPressed: () => Navigator.of(context).pop(true),
|
||||||
child: const Text(
|
child: const Text(
|
||||||
|
|||||||
@@ -224,6 +224,14 @@ class _FileExplorerState extends State<FileExplorer> {
|
|||||||
TextButton(
|
TextButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
splashFactory: NoSplash.splashFactory,
|
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(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
child: const Text(
|
child: const Text(
|
||||||
@@ -234,6 +242,14 @@ class _FileExplorerState extends State<FileExplorer> {
|
|||||||
TextButton(
|
TextButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
splashFactory: NoSplash.splashFactory,
|
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: () {
|
onPressed: () {
|
||||||
final folderName = controller.text.trim();
|
final folderName = controller.text.trim();
|
||||||
@@ -337,6 +353,14 @@ class _FileExplorerState extends State<FileExplorer> {
|
|||||||
TextButton(
|
TextButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
splashFactory: NoSplash.splashFactory,
|
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(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
child: const Text(
|
child: const Text(
|
||||||
@@ -347,6 +371,14 @@ class _FileExplorerState extends State<FileExplorer> {
|
|||||||
TextButton(
|
TextButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
splashFactory: NoSplash.splashFactory,
|
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: () {
|
onPressed: () {
|
||||||
final docName = controller.text.trim();
|
final docName = controller.text.trim();
|
||||||
@@ -535,6 +567,14 @@ class _FileExplorerState extends State<FileExplorer> {
|
|||||||
TextButton(
|
TextButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
splashFactory: NoSplash.splashFactory,
|
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(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
child: const Text(
|
child: const Text(
|
||||||
@@ -545,6 +585,14 @@ class _FileExplorerState extends State<FileExplorer> {
|
|||||||
TextButton(
|
TextButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
splashFactory: NoSplash.splashFactory,
|
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: () {
|
onPressed: () {
|
||||||
final newName = controller.text.trim();
|
final newName = controller.text.trim();
|
||||||
@@ -759,6 +807,14 @@ class _FileExplorerState extends State<FileExplorer> {
|
|||||||
TextButton(
|
TextButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
splashFactory: NoSplash.splashFactory,
|
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),
|
onPressed: () => Navigator.of(context).pop(false),
|
||||||
child: const Text(
|
child: const Text(
|
||||||
@@ -769,6 +825,14 @@ class _FileExplorerState extends State<FileExplorer> {
|
|||||||
TextButton(
|
TextButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
splashFactory: NoSplash.splashFactory,
|
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),
|
onPressed: () => Navigator.of(context).pop(true),
|
||||||
child: const Text(
|
child: const Text(
|
||||||
@@ -1428,10 +1492,25 @@ class _FileExplorerState extends State<FileExplorer> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
children: state.breadcrumbs.map((breadcrumb) {
|
children: state.breadcrumbs.map((breadcrumb) {
|
||||||
return TextButton(
|
return TextButton(
|
||||||
style: TextButton.styleFrom(
|
style: ButtonStyle(
|
||||||
splashFactory: NoSplash.splashFactory,
|
splashFactory: NoSplash.splashFactory,
|
||||||
padding: EdgeInsets.zero,
|
overlayColor:
|
||||||
minimumSize: Size.zero,
|
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:
|
tapTargetSize:
|
||||||
MaterialTapTargetSize.shrinkWrap,
|
MaterialTapTargetSize.shrinkWrap,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -238,7 +238,17 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
|
|||||||
final highlightColor = const Color.fromARGB(255, 100, 200, 255);
|
final highlightColor = const Color.fromARGB(255, 100, 200, 255);
|
||||||
final defaultColor = AppTheme.secondaryText;
|
final defaultColor = AppTheme.secondaryText;
|
||||||
return TextButton(
|
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,
|
onPressed: onTap,
|
||||||
child: Text(
|
child: Text(
|
||||||
org.name,
|
org.name,
|
||||||
@@ -254,7 +264,17 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
|
|||||||
final highlightColor = const Color.fromARGB(255, 100, 200, 255);
|
final highlightColor = const Color.fromARGB(255, 100, 200, 255);
|
||||||
final defaultColor = AppTheme.secondaryText;
|
final defaultColor = AppTheme.secondaryText;
|
||||||
return TextButton(
|
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,
|
onPressed: onTap,
|
||||||
child: Text(
|
child: Text(
|
||||||
'Personal',
|
'Personal',
|
||||||
@@ -269,7 +289,17 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
|
|||||||
Widget _buildAddButton(VoidCallback onTap) {
|
Widget _buildAddButton(VoidCallback onTap) {
|
||||||
final defaultColor = AppTheme.secondaryText;
|
final defaultColor = AppTheme.secondaryText;
|
||||||
return TextButton(
|
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,
|
onPressed: onTap,
|
||||||
child: Text('+ Add Organization', style: TextStyle(color: defaultColor)),
|
child: Text('+ Add Organization', style: TextStyle(color: defaultColor)),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user