Line data Source code
1 : import 'package:cached_network_image/cached_network_image.dart';
2 : import 'package:dotted_border/dotted_border.dart';
3 : import 'package:flutter/material.dart';
4 : import 'package:flutter/services.dart';
5 : import 'package:flutter/widgets.dart';
6 : import 'package:pal/src/theme.dart';
7 : import 'package:pal/src/ui/shared/widgets/circle_button.dart';
8 :
9 : class EditableMedia extends StatelessWidget {
10 : final double mediaSize;
11 : final String url;
12 : final Function onEdit;
13 : final String editKey;
14 :
15 2 : EditableMedia({
16 : Key key,
17 : this.url,
18 : this.mediaSize = 200.0,
19 : this.onEdit,
20 : @required this.editKey,
21 2 : }) : super(key: key);
22 :
23 2 : @override
24 : Widget build(BuildContext context) {
25 2 : return DottedBorder(
26 2 : dashPattern: [6, 3],
27 2 : color: Colors.white.withAlpha(80),
28 2 : child: Padding(
29 : padding: const EdgeInsets.all(8.0),
30 2 : child: Stack(
31 2 : children: [
32 5 : (url != null && url.length > 0)
33 1 : ? CachedNetworkImage(
34 1 : imageUrl: url,
35 1 : width: mediaSize,
36 2 : placeholder: (context, url) => Center(
37 1 : child: CircularProgressIndicator(),
38 : ),
39 0 : errorWidget: (context, url, error) => Center(
40 0 : child: Icon(Icons.error),
41 : ),
42 : )
43 2 : : Icon(
44 : Icons.image,
45 2 : size: mediaSize,
46 2 : color: Colors.white.withAlpha(80),
47 : ),
48 2 : Positioned(
49 : bottom: 0.0,
50 : right: 0.0,
51 2 : child: CircleIconButton(
52 4 : key: ValueKey(editKey),
53 2 : icon: Icon(Icons.edit),
54 6 : backgroundColor: PalTheme.of(context).colors.light,
55 0 : onTapCallback: () {
56 0 : if (onEdit != null) {
57 0 : HapticFeedback.selectionClick();
58 0 : onEdit();
59 : }
60 : },
61 : ),
62 : ),
63 : ],
64 : ),
65 : ),
66 : );
67 : }
68 : }
|