Skip to content

Commit

Permalink
remove unused widget
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlyp committed Nov 14, 2023
1 parent b2bb7a1 commit 4fd4d1d
Showing 1 changed file with 0 additions and 220 deletions.
220 changes: 0 additions & 220 deletions bruig/flutterui/bruig/lib/components/chat/events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -283,226 +283,6 @@ class _ReceivedSentPMState extends State<ReceivedSentPM> {
}
}

class ReceivedSentMobileGCMsg extends StatefulWidget {
final ChatEventModel evnt;
final String nick;
final int timestamp;
final ShowSubMenuCB showSubMenu;
final String id;
final String userNick;
final bool isGC;

const ReceivedSentMobileGCMsg(this.evnt, this.nick, this.timestamp,
this.showSubMenu, this.id, this.userNick, this.isGC,
{Key? key})
: super(key: key);

@override
State<ReceivedSentMobileGCMsg> createState() =>
_ReceivedSentMobileGCMsgState();
}

class _ReceivedSentMobileGCMsgState extends State<ReceivedSentMobileGCMsg> {
void eventChanged() => setState(() {});

@override
initState() {
super.initState();
widget.evnt.addListener(eventChanged);
}

@override
didUpdateWidget(ReceivedSentMobileGCMsg oldWidget) {
super.didUpdateWidget(oldWidget);
oldWidget.evnt.removeListener(eventChanged);
widget.evnt.addListener(eventChanged);
}

@override
dispose() {
widget.evnt.removeListener(eventChanged);
super.dispose();
}

Future<void> launchUrlAwait(url) async {
if (!await launchUrl(Uri.parse(url))) {
throw 'Could not launch $url';
}
}

@override
Widget build(BuildContext context) {
var prefix = "";
var suffix = "";
switch (widget.evnt.sentState) {
case CMS_sending:
prefix = "…";
break;
case CMS_sent:
prefix = "✓";
break;
case CMS_errored:
prefix = "✗";
suffix = "\n\n${widget.evnt.sendError}";
break;
default:
}
var sourceID = widget.evnt.event.sid;
if (widget.evnt.source != null) {
sourceID = widget.evnt.source!.id;
}
var now = DateTime.fromMillisecondsSinceEpoch(widget.timestamp);
var hour = DateFormat('HH:mm').format(now);
var fullDate = DateFormat("yyyy-MM-dd HH:mm:ss").format(now);

var msg = "${widget.evnt.event.msg}$suffix";
msg = msg.replaceAll("\n",
" \n"); // Replace newlines with <space space newline> for proper md render
var theme = Theme.of(context);
var darkTextColor = theme.indicatorColor;
var hightLightTextColor = theme.dividerColor; // NAME TEXT COLOR
var avatarColor = colorFromNick(widget.nick);
var avatarTextColor =
ThemeData.estimateBrightnessForColor(avatarColor) == Brightness.dark
? hightLightTextColor
: darkTextColor;
var selectedBackgroundColor = theme.highlightColor;
var textColor = theme.dividerColor;
var messageBackgroundColor = theme.dialogBackgroundColor;

return Consumer<ThemeNotifier>(
builder: (context, theme, _) => Column(children: [
widget.evnt.firstUnread
? Row(children: [
Expanded(
child: Divider(
color: textColor, //color of divider
height: 8, //height spacing of divider
thickness: 1, //thickness of divier line
indent: 5, //spacing at the start of divider
endIndent: 5, //spacing at the end of divider
)),
Text("Last read posts",
style: TextStyle(
fontSize: theme.getSmallFont(context),
color: textColor)),
Expanded(
child: Divider(
color: textColor, //color of divider
height: 8, //height spacing of divider
thickness: 1, //thickness of divier line
indent: 5, //spacing at the start of divider
endIndent: 5, //spacing at the end of divider
)),
])
: const Empty(),
Container(
margin: const EdgeInsets.only(left: 5, right: 20),
padding: const EdgeInsets.only(
left: 10, right: 10, top: 5, bottom: 5),
decoration: BoxDecoration(
color: messageBackgroundColor,
borderRadius: BorderRadius.circular(10),
),
child: Row(children: [
Flexible(
child: Column(children: [
SelectionContainer.disabled(
child: Container(
width: 28,
margin: const EdgeInsets.only(
top: 0, bottom: 0, left: 5, right: 0),
child: widget.isGC
? UserContextMenu(
targetUserChat: widget.evnt.source,
child: InteractiveAvatar(
bgColor: selectedBackgroundColor,
chatNick: widget.nick,
avatarColor: avatarColor,
avatarTextColor: avatarTextColor,
),
)
: UserContextMenu(
targetUserChat: widget.evnt.source,
child: InteractiveAvatar(
bgColor: selectedBackgroundColor,
chatNick: widget.nick,
onTap: () {
widget.showSubMenu(
widget.isGC, widget.id);
},
avatarColor: avatarColor,
avatarTextColor: avatarTextColor,
),
),
),
),
])),
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Flexible(
child: Text(
widget.nick,
style: TextStyle(
fontSize: theme.getSmallFont(context),
color: avatarColor, // NAME TEXT COLOR,
fontWeight: FontWeight.bold,
),
)),
Flexible(
child: SelectionContainer.disabled(
child: Padding(
padding: const EdgeInsets.all(4.0),
child: Tooltip(
message: fullDate,
child: Text(
hour,
style: TextStyle(
fontSize:
theme.getSmallFont(context),
color: darkTextColor), // DATE COLOR
)),
)))
]),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Flexible(
child: Provider<DownloadSource>(
create: (context) =>
DownloadSource(sourceID),
child: MarkdownArea(
msg,
widget.userNick != widget.nick &&
msg.contains(widget.userNick)))),
Flexible(
child: SelectionContainer.disabled(
child: SizedBox(
width: 5,
child: Text(
prefix,
style: TextStyle(
fontSize: theme.getSmallFont(context),
color:
hightLightTextColor, // NAME TEXT COLOR,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.italic),
)),
))
],
),
const SizedBox(width: 10)
]),
const SizedBox(height: 5),
]))
]));
}
}

class ReceivedSentMobilePM extends StatefulWidget {
final ChatEventModel evnt;
final String nick;
Expand Down

0 comments on commit 4fd4d1d

Please sign in to comment.