Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions commet/lib/ui/organisms/user_profile/user_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -511,15 +511,17 @@ class _UserProfileState extends State<UserProfile> {
}

Future<void> clearBio() async {
setState(() {
bioText = null;
});
if (await AdaptiveDialog.confirmation(context) == true) {
setState(() {
bioText = null;
});

await widget.client.getComponent<UserProfileComponent>()?.removeBio();
await widget.client.getComponent<UserProfileComponent>()?.removeBio();

component.getProfile(widget.userId).then((value) async {
await stateFromProfile(value);
});
component.getProfile(widget.userId).then((value) async {
await stateFromProfile(value);
});
}
}

String get labelProfileYourBadges => Intl.message("Your Badges",
Expand Down
129 changes: 89 additions & 40 deletions commet/lib/ui/organisms/user_profile/user_profile_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,9 @@ class UserProfileViewState extends State<UserProfileView> {
CrossAxisAlignment
.end,
children: [
if (localTime != null)
if (localTime != null &&
widget.timezone !=
null)
userLocalTime(),
badges(),
],
Expand Down Expand Up @@ -493,54 +495,49 @@ class UserProfileViewState extends State<UserProfileView> {
List<tiamat.ContextMenuItem> contextMenuItems(BuildContext context) {
return [
if (widget.isSelf)
tiamat.ContextMenuItem(
profileMenuItem(
text: promptProfileChangeBanner,
onPressed: () => widget.onSetBanner?.call(),
icon: Icons.image),
if (widget.isSelf)
tiamat.ContextMenuItem(
profileMenuItem(
text: promptProfileSetStatus,
onPressed: () => widget.onSetStatus?.call(),
onClearPressed: widget.presence?.message != null
? () => widget.clearStatus?.call()
: null,
icon: Icons.short_text),
if (widget.isSelf && widget.presence?.message != null)
tiamat.ContextMenuItem(
text: promptProfileClearStatus,
onPressed: () => widget.clearStatus?.call(),
icon: Icons.delete),
if (widget.isSelf)
tiamat.ContextMenuItem(
profileMenuItem(
text: promptProfileSetBadges,
onPressed: () => widget.editBadges?.call(),
icon: Icons.star),
if (widget.isSelf)
tiamat.ContextMenuItem(
profileMenuItem(
text: promptProfileSetBio,
onPressed: () => widget.setBio?.call(),
icon: Icons.text_snippet),
if (widget.isSelf && widget.bio != null)
tiamat.ContextMenuItem(
text: promptProfileClearBio,
onPressed: () => widget.clearBio?.call(),
icon: Icons.delete),
icon: Icons.text_snippet,
onClearPressed: () => widget.clearBio?.call()),
if (widget.isSelf)
tiamat.ContextMenuItem(
profileMenuItem(
text: promptProfileShareTimezone,
onPressed: () => widget.shareCurrentTimezone?.call(),
icon: Icons.share_arrival_time),
if (widget.isSelf && widget.timezone != null)
tiamat.ContextMenuItem(
text: promptProfileClearTimezone,
onPressed: () => widget.removeTimezone?.call(),
icon: Icons.timer_off),
icon: Icons.share_arrival_time,
onClearPressed: widget.timezone != null
? () => widget.removeTimezone?.call()
: null),
if (widget.isSelf)
tiamat.ContextMenuItem(
profileMenuItem(
text: promptProfileEditColorScheme,
onPressed: () => setState(() {
editingColorScheme = true;
}),
icon: Icons.color_lens),
tiamat.ContextMenuItem(
profileMenuItem(
text: promptProfileSetColorOverride,
onClearPressed: widget.hasColorOverride
? () => widget.setColorOverride?.call(null)
: null,
onPressed: () async {
var color = await AdaptiveDialog.show<Color>(
title: promptProfileSetColorOverride,
Expand Down Expand Up @@ -587,9 +584,11 @@ class UserProfileViewState extends State<UserProfileView> {
}
},
icon: Icons.colorize),
tiamat.ContextMenuItem(
profileMenuItem(
text: "Set Nickame",
icon: Icons.badge,
onClearPressed:
widget.hasPetName ? () => widget.setPetName?.call(null) : null,
onPressed: () async {
final text = await AdaptiveDialog.textPrompt(
context,
Expand All @@ -602,27 +601,77 @@ class UserProfileViewState extends State<UserProfileView> {
}
},
),
if (widget.hasPetName)
tiamat.ContextMenuItem(
text: "Clear Nickname",
icon: Icons.remove,
onPressed: () => widget.setPetName?.call(null),
),
if (widget.hasColorOverride)
tiamat.ContextMenuItem(
text: promptProfileClearColorOverride,
icon: Icons.remove,
onPressed: () async {
widget.setColorOverride?.call(null);
}),
if (preferences.developerMode.value)
tiamat.ContextMenuItem(
profileMenuItem(
text: promptProfileShowRawProfile,
onPressed: () => widget.showSource?.call(),
icon: Icons.code),
];
}

tiamat.ContextMenuItem profileMenuItem(
{required String text,
required IconData icon,
required Function onPressed,
Function? onClearPressed}) {
return tiamat.ContextMenuItem(
text: text,
icon: icon,
onPressed: onPressed,
customBuilder: (context, onClicked, {closeMenu}) {
var c = Theme.of(context).colorScheme.onSurface;

return Material(
color: Colors.transparent,
child: Padding(
padding: const EdgeInsets.all(4.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max,
spacing: 8,
children: [
Expanded(
child: InkWell(
onTap: onClicked,
borderRadius: BorderRadius.circular(8),
child: Container(
padding: const EdgeInsets.fromLTRB(4, 8, 4, 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
spacing: 8,
children: [
Icon(
icon,
color: c,
size: 20,
),
tiamat.Text(text,
type: tiamat.TextType.body,
maxLines: 1,
color: c),
],
))),
),
if (onClearPressed != null)
tiamat.IconButton(
icon: Icons.close,
size: 18,
iconColor: Colors.red,
onPressed: () {
onClearPressed.call();
closeMenu?.call();
},
),
],
),
),
);
},
);
}

Widget buildColorSchemeEditor() {
var run = 8;
var count = run * 2;
Expand Down
2 changes: 1 addition & 1 deletion tiamat/lib/atoms/context_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class ContextMenuItem {
return Material(
color: Colors.transparent,
child: Padding(
padding: const EdgeInsets.all(3.0),
padding: const EdgeInsets.all(4.0),
child: InkWell(
onTap: onClicked,
borderRadius: BorderRadius.circular(8),
Expand Down
Loading