🐛 Fix app bar buttons clicking event got absorb by indicators

This commit is contained in:
LittleSheep 2025-01-21 14:47:13 +08:00
parent bb7b731602
commit 9b34f385d5
2 changed files with 78 additions and 69 deletions

View File

@ -18,8 +18,11 @@ class ConnectionIndicator extends StatelessWidget {
listenable: ws, listenable: ws,
builder: (context, _) { builder: (context, _) {
final ua = context.read<UserProvider>(); final ua = context.read<UserProvider>();
final show = (ws.isBusy || !ws.isConnected) && ua.isAuthorized;
return GestureDetector( return IgnorePointer(
ignoring: !show,
child: GestureDetector(
child: Material( child: Material(
elevation: 2, elevation: 2,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(16))), shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(16))),
@ -48,7 +51,7 @@ class ConnectionIndicator extends StatelessWidget {
], ],
).padding(horizontal: 8, vertical: 4) ).padding(horizontal: 8, vertical: 4)
: const SizedBox.shrink(), : const SizedBox.shrink(),
).opacity((ws.isBusy || !ws.isConnected) && ua.isAuthorized ? 1 : 0, animate: true).animate( ).opacity(show ? 1 : 0, animate: true).animate(
const Duration(milliseconds: 300), const Duration(milliseconds: 300),
Curves.easeInOut, Curves.easeInOut,
), ),
@ -57,6 +60,7 @@ class ConnectionIndicator extends StatelessWidget {
ws.connect(); ws.connect();
} }
}, },
),
); );
}, },
); );

View File

@ -15,10 +15,14 @@ class NotifyIndicator extends StatelessWidget {
final ua = context.read<UserProvider>(); final ua = context.read<UserProvider>();
final nty = context.watch<NotificationProvider>(); final nty = context.watch<NotificationProvider>();
final show = nty.notifications.isNotEmpty && ua.isAuthorized;
return ListenableBuilder( return ListenableBuilder(
listenable: nty, listenable: nty,
builder: (context, _) { builder: (context, _) {
return GestureDetector( return IgnorePointer(
ignoring: !show,
child: GestureDetector(
child: Material( child: Material(
elevation: 2, elevation: 2,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(16))), shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(16))),
@ -45,13 +49,14 @@ class NotifyIndicator extends StatelessWidget {
], ],
).padding(horizontal: 8, vertical: 4) ).padding(horizontal: 8, vertical: 4)
: const SizedBox.shrink(), : const SizedBox.shrink(),
).opacity(nty.notifications.isNotEmpty && ua.isAuthorized ? 1 : 0, animate: true).animate( ).opacity(show ? 1 : 0, animate: true).animate(
const Duration(milliseconds: 300), const Duration(milliseconds: 300),
Curves.easeInOut, Curves.easeInOut,
), ),
onTap: () { onTap: () {
nty.clear(); nty.clear();
}, },
),
); );
}); });
} }