Tweak selectable style

This commit is contained in:
Ming Ming 2021-09-28 19:14:47 +08:00
parent c494a9f33e
commit 2cafe8e184
2 changed files with 28 additions and 15 deletions

View file

@ -44,12 +44,6 @@ class AppTheme extends StatelessWidget {
: primarySwatchDark[700]!.withOpacity(0.7); : primarySwatchDark[700]!.withOpacity(0.7);
} }
static Color getSelectionCheckColor(BuildContext context) {
return Theme.of(context).brightness == Brightness.light
? Colors.grey[800]!
: Colors.grey[350]!;
}
static Color getOverscrollIndicatorColor(BuildContext context) { static Color getOverscrollIndicatorColor(BuildContext context) {
return Theme.of(context).brightness == Brightness.light return Theme.of(context).brightness == Brightness.light
? Colors.grey[800]! ? Colors.grey[800]!

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:nc_photos/k.dart' as k;
import 'package:nc_photos/theme.dart'; import 'package:nc_photos/theme.dart';
// Overlay a check mark if an item is selected // Overlay a check mark if an item is selected
@ -19,7 +20,6 @@ class Selectable extends StatelessWidget {
return Stack( return Stack(
fit: StackFit.expand, fit: StackFit.expand,
children: [ children: [
child,
if (isSelected) if (isSelected)
Positioned.fill( Positioned.fill(
child: Container( child: Container(
@ -27,16 +27,35 @@ class Selectable extends StatelessWidget {
color: AppTheme.getSelectionOverlayColor(context), color: AppTheme.getSelectionOverlayColor(context),
borderRadius: borderRadius, borderRadius: borderRadius,
), ),
child: Align(
alignment: Alignment.center,
child: Icon(
Icons.check_circle_outlined,
size: iconSize,
color: AppTheme.getSelectionCheckColor(context),
),
),
), ),
), ),
AnimatedScale(
scale: isSelected ? .85 : 1,
curve: Curves.easeInOut,
duration: k.animationDurationNormal,
child: child,
),
Positioned.fill(
child: AnimatedOpacity(
opacity: isSelected ? 1 : 0,
duration: k.animationDurationNormal,
child: Stack(
alignment: AlignmentDirectional.center,
children: [
Icon(
Icons.circle,
size: iconSize,
color: Theme.of(context).colorScheme.primary,
),
Icon(
Icons.check_circle_outlined,
size: iconSize,
color: Colors.white,
),
],
),
),
),
if (onTap != null || onLongPress != null) if (onTap != null || onLongPress != null)
Positioned.fill( Positioned.fill(
child: Material( child: Material(