70 lines
2.1 KiB
Dart
70 lines
2.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:manager_app/constants.dart';
|
|
|
|
class CardShape {
|
|
final int col;
|
|
final int row;
|
|
const CardShape(this.col, this.row);
|
|
}
|
|
|
|
/// Les 4 formes proposées pour une card dans la grille bento.
|
|
const List<CardShape> kCardShapes = [
|
|
CardShape(1, 1), // standard
|
|
CardShape(2, 1), // large
|
|
CardShape(1, 2), // haute
|
|
CardShape(2, 2), // grande vedette
|
|
];
|
|
|
|
/// Sélecteur de forme compact — raccourci équivalent au drag de coin dans
|
|
/// l'aperçu (les deux écrivent gridColSpan/gridRowSpan sur le même lien).
|
|
class CardShapeSelector extends StatelessWidget {
|
|
final int colSpan;
|
|
final int rowSpan;
|
|
final void Function(int col, int row) onChanged;
|
|
|
|
const CardShapeSelector({
|
|
super.key,
|
|
required this.colSpan,
|
|
required this.rowSpan,
|
|
required this.onChanged,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(3),
|
|
decoration: BoxDecoration(
|
|
color: kSecond.withValues(alpha: 0.4),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: kCardShapes.map((shape) {
|
|
final isSelected = shape.col == colSpan && shape.row == rowSpan;
|
|
return GestureDetector(
|
|
onTap: () => onChanged(shape.col, shape.row),
|
|
child: Container(
|
|
width: 26,
|
|
height: 26,
|
|
margin: const EdgeInsets.symmetric(horizontal: 2),
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
color: isSelected ? kPrimaryColor : Colors.transparent,
|
|
borderRadius: BorderRadius.circular(6),
|
|
),
|
|
child: Container(
|
|
width: shape.col == 2 ? 16 : 8,
|
|
height: shape.row == 2 ? 16 : 8,
|
|
decoration: BoxDecoration(
|
|
color: isSelected ? kWhite : kBodyTextColor,
|
|
borderRadius: BorderRadius.circular(2),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}).toList(),
|
|
),
|
|
);
|
|
}
|
|
}
|