ente/lib/ui/map/marker_image.dart

67 lines
1.8 KiB
Dart
Raw Normal View History

import "package:flutter/material.dart";
import "package:photos/models/file.dart";
2023-06-10 16:24:16 +00:00
import "package:photos/theme/effects.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/viewer/file/thumbnail_widget.dart";
class MarkerImage extends StatelessWidget {
final File file;
final double seperator;
const MarkerImage({super.key, required this.file, required this.seperator});
@override
Widget build(BuildContext context) {
2023-06-10 16:24:16 +00:00
final bgColor = getEnteColorScheme(context).backgroundElevated2;
return Container(
decoration: BoxDecoration(boxShadow: shadowMenuLight),
child: Stack(
children: <Widget>[
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
border: Border.all(
color: bgColor,
width: 2,
),
),
2023-06-10 16:24:16 +00:00
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(2)),
child: ThumbnailWidget(file),
),
),
2023-06-10 16:24:16 +00:00
Align(
alignment: Alignment.bottomCenter,
child: Container(
margin: EdgeInsets.only(top: seperator),
child: CustomPaint(
painter: MarkerPointer(bgColor),
),
),
2023-08-19 11:39:56 +00:00
),
2023-06-10 16:24:16 +00:00
],
),
);
}
}
class MarkerPointer extends CustomPainter {
2023-06-10 16:24:16 +00:00
Color bgColor;
MarkerPointer(this.bgColor);
@override
void paint(Canvas canvas, Size size) {
2023-06-10 16:24:16 +00:00
final paint = Paint()..color = bgColor;
final path = Path();
2023-06-10 16:24:16 +00:00
path.moveTo(9, -12);
path.lineTo(0, -4);
path.lineTo(-9, -12);
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(MarkerPointer oldDelegate) {
return bgColor != oldDelegate.bgColor;
}
}