Line data Source code
1 : import 'package:cwtch/cwtch_icons_icons.dart';
2 : import 'package:cwtch/models/messagecache.dart';
3 : import 'package:cwtch/models/contact.dart';
4 : import 'package:cwtch/models/profile.dart';
5 : import 'package:cwtch/l10n/app_localizations.dart';
6 : import 'package:provider/provider.dart';
7 : import 'package:flutter/material.dart';
8 :
9 : import '../settings.dart';
10 : import '../models/message.dart';
11 : import '../themes/opaque.dart';
12 :
13 : // HiddenBubble is displayed for messages hidden by a moderator
14 : class HiddenBubble extends StatefulWidget {
15 : final MessageInfo messageInfo;
16 :
17 0 : HiddenBubble(this.messageInfo);
18 :
19 0 : @override
20 0 : HiddenBubbleState createState() => HiddenBubbleState();
21 : }
22 :
23 : class HiddenBubbleState extends State<HiddenBubble> {
24 0 : @override
25 : Widget build(BuildContext context) {
26 0 : var profile = Provider.of<ProfileInfoState>(context, listen: false);
27 0 : var conversation = Provider.of<ContactInfoState>(context);
28 0 : bool couldMod = ['admin', 'op', 'mod'].contains(conversation.getRole(profile.onion));
29 :
30 0 : return Container(
31 0 : decoration: BoxDecoration(
32 0 : color: Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor,
33 0 : border: Border.all(color: Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor, width: 1),
34 0 : borderRadius: BorderRadius.only(topLeft: Radius.zero, topRight: Radius.zero, bottomLeft: Radius.zero, bottomRight: Radius.zero),
35 : ),
36 0 : child: FittedBox(
37 : fit: BoxFit.contain,
38 0 : child: Center(
39 : widthFactor: 1.0,
40 0 : child: Padding(
41 0 : padding: EdgeInsets.all(9.0),
42 0 : child: Row(
43 : mainAxisSize: MainAxisSize.min,
44 0 : children: [
45 0 : Center(
46 : widthFactor: 1,
47 0 : child: Padding(padding: EdgeInsets.all(4), child: Icon(CwtchIcons.eye_closed, size: 24)),
48 : ),
49 0 : Center(
50 : widthFactor: 1.0,
51 0 : child: Text(
52 : "t9n(Message hidden by a moderator.)",
53 0 : style: Provider.of<Settings>(context).scaleFonts(defaultMessageTextStyle),
54 : overflow: TextOverflow.ellipsis,
55 : textWidthBasis: TextWidthBasis.longestLine,
56 : ),
57 : ),
58 0 : Visibility(
59 : visible: couldMod,
60 0 : child: IconButton(
61 : enableFeedback: true,
62 0 : splashRadius: Material.defaultSplashRadius / 2,
63 : tooltip: "t9n(Preview)",
64 0 : icon: Icon(Icons.preview, color: Provider.of<Settings>(context).current().mainTextColor),
65 0 : onPressed: () {
66 0 : modalPreviewMessage(context, widget.messageInfo);
67 : },
68 : ),
69 : ),
70 : ],
71 : ),
72 : ),
73 : ),
74 : ),
75 : );
76 : }
77 : }
|