Skip to content

Commit d5739bb

Browse files
committed
Refactor context menus and buttons to use Label
1 parent b7f80aa commit d5739bb

File tree

4 files changed

+39
-69
lines changed

4 files changed

+39
-69
lines changed

DistributedChatApp/View/ChannelsView.swift

+6-12
Original file line numberDiff line numberDiff line change
@@ -43,43 +43,37 @@ struct ChannelsView: View {
4343
deletingChannels = [channel]
4444
deletionConfirmationShown = true
4545
} label: {
46-
Text("Delete Locally")
47-
Image(systemName: "trash")
46+
Label("Delete Locally", systemImage: "trash")
4847
}
4948
if messages.unreadChannels.contains(channel) {
5049
Button {
5150
messages.markAsRead(channel: channel)
5251
} label: {
53-
Text("Mark as Read")
54-
Image(systemName: "circlebadge")
52+
Label("Mark as Read", systemImage: "circlebadge")
5553
}
5654
}
5755
if !messages.pinnedChannels.contains(channel) {
5856
Button {
5957
messages.pin(channel: channel)
6058
} label: {
61-
Text("Pin")
62-
Image(systemName: "pin.fill")
59+
Label("Pin", systemImage: "pin.fill")
6360
}
6461
} else if channel != .global {
6562
Button {
6663
messages.unpin(channel: channel)
6764
} label: {
68-
Text("Unpin")
69-
Image(systemName: "pin.slash.fill")
65+
Label("Unpin", systemImage: "pin.slash.fill")
7066
}
7167
}
7268
Button {
7369
UIPasteboard.general.string = channel.displayName(with: network)
7470
} label: {
75-
Text("Copy Channel Name")
76-
Image(systemName: "doc.on.doc")
71+
Label("Copy Channel Name", systemImage: "doc.on.doc")
7772
}
7873
Button {
7974
UIPasteboard.general.url = URL(string: "distributedchat:///channel/\(channel)")
8075
} label: {
81-
Text("Copy Channel URL")
82-
Image(systemName: "doc.on.doc.fill")
76+
Label("Copy Channel URL", systemImage: "doc.on.doc.fill")
8377
}
8478
}
8579
}

DistributedChatApp/View/MessageView.swift

+23-37
Original file line numberDiff line numberDiff line change
@@ -23,83 +23,69 @@ struct MessageView: View {
2323
Button {
2424
messages.deleteMessage(id: message.id)
2525
} label: {
26-
Text("Delete Locally")
27-
Image(systemName: "trash")
26+
Label("Delete Locally", systemImage: "trash")
2827
}
2928
Button {
3029
replyingToMessageId = message.id
3130
} label: {
32-
Text("Reply")
33-
Image(systemName: "arrowshape.turn.up.left.fill")
31+
Label("Reply", systemImage: "arrowshape.turn.up.left.fill")
3432
}
3533
if messages.unreadMessageIds.contains(message.id) {
3634
Button {
3735
messages.unreadMessageIds.remove(message.id)
3836
} label: {
39-
Text("Mark as Read")
40-
Image(systemName: "circlebadge")
37+
Label("Mark as Read", systemImage: "circlebadge")
4138
}
4239
} else {
4340
Button {
4441
messages.unreadMessageIds.insert(message.id)
4542
} label: {
46-
Text("Mark as Unread")
47-
Image(systemName: "circlebadge.fill")
43+
Label("Mark as Unread", systemImage: "circlebadge.fill")
4844
}
4945
}
5046
if !message.displayContent.isEmpty {
5147
ShareLink(item: message.displayContent) {
52-
Text("Share Text")
53-
Image(systemName: "square.and.arrow.up")
48+
Label("Share Text", systemImage: "square.and.arrow.up")
5449
}
5550
}
5651
ForEach(message.attachments ?? []) { attachment in
5752
if let url = attachment.content.asURL {
5853
ShareLink(item: url.smartResolved) {
59-
Text("Share \(attachment.type) (\(attachment.name))")
60-
Image(systemName: "square.and.arrow.up")
54+
Label("Share \(attachment.type) (\(attachment.name))", systemImage: "square.and.arrow.up")
6155
}
6256
}
6357
}
6458
if !message.displayContent.isEmpty {
6559
Button {
6660
UIPasteboard.general.string = message.displayContent
6761
} label: {
68-
Text("Copy Text")
69-
Image(systemName: "doc.on.doc")
62+
Label("Copy Text", systemImage: "doc.on.doc")
7063
}
7164
}
7265
Button {
7366
UIPasteboard.general.string = message.id.uuidString
7467
} label: {
75-
Text("Copy Message ID")
76-
Image(systemName: "doc.on.doc")
68+
Label("Copy Message ID", systemImage: "doc.on.doc")
7769
}
7870
Button {
7971
UIPasteboard.general.url = URL(string: "distributedchat:///message/\(message.id)")
8072
} label: {
81-
Text("Copy Message URL")
82-
Image(systemName: "doc.on.doc.fill")
73+
Label("Copy Message URL", systemImage: "doc.on.doc.fill")
8374
}
84-
Group {
85-
Button {
86-
UIPasteboard.general.string = message.author.id.uuidString
87-
} label: {
88-
Text("Copy Author ID")
89-
Image(systemName: "doc.on.doc")
90-
}
91-
Button {
92-
UIPasteboard.general.string = message.author.name
93-
} label: {
94-
Text("Copy Author Name")
95-
Image(systemName: "doc.on.doc")
96-
}
97-
Button {
98-
navigation.open(channel: .dm([controller.me.id, message.author.id]))
99-
} label: {
100-
Text("Open DM channel")
101-
Image(systemName: "at")
102-
}
75+
Button {
76+
UIPasteboard.general.string = message.author.id.uuidString
77+
} label: {
78+
Label("Copy Author ID", systemImage: "doc.on.doc")
79+
}
80+
Button {
81+
UIPasteboard.general.string = message.author.name
82+
} label: {
83+
Label("Copy Author Name", systemImage: "doc.on.doc")
84+
}
85+
Button {
86+
navigation.open(channel: .dm([controller.me.id, message.author.id]))
87+
} label: {
88+
Label("Open DM channel", systemImage: "at")
10389
}
10490
}
10591

DistributedChatApp/View/NetworkView.swift

+6-12
Original file line numberDiff line numberDiff line change
@@ -31,42 +31,36 @@ struct NetworkView: View {
3131
Button {
3232
UIPasteboard.general.string = chatUser.id.uuidString
3333
} label: {
34-
Text("Copy User ID")
35-
Image(systemName: "doc.on.doc")
34+
Label("Copy User ID", systemImage: "doc.on.doc")
3635
}
3736
Button {
3837
UIPasteboard.general.string = chatUser.name
3938
} label: {
40-
Text("Copy User Name")
41-
Image(systemName: "doc.on.doc")
39+
Label("Copy User Name", systemImage: "doc.on.doc")
4240
}
4341
Button {
4442
navigation.open(channel: .dm([network.myId, chatUser.id]))
4543
} label: {
46-
Text("Open DM channel")
47-
Image(systemName: "at")
44+
Label("Open DM channel", systemImage: "at")
4845
}
4946
}
5047
Button {
5148
UIPasteboard.general.string = user.peripheralIdentifier.uuidString
5249
} label: {
53-
Text("Copy Peripheral ID")
54-
Image(systemName: "doc.on.doc")
50+
Label("Copy Peripheral ID", systemImage: "doc.on.doc")
5551
}
5652
if let peripheralName = user.peripheralName {
5753
Button {
5854
UIPasteboard.general.string = peripheralName
5955
} label: {
60-
Text("Copy Peripheral Name")
61-
Image(systemName: "doc.on.doc")
56+
Label("Copy Peripheral Name", systemImage: "doc.on.doc")
6257
}
6358
}
6459
if let rssi = user.rssi {
6560
Button {
6661
UIPasteboard.general.string = String(rssi)
6762
} label: {
68-
Text("Copy RSSI")
69-
Image(systemName: "doc.on.doc")
63+
Label("Copy RSSI", systemImage: "doc.on.doc")
7064
}
7165
}
7266
}

DistributedChatApp/View/PresenceView.swift

+4-8
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,24 @@ struct PresenceView: View {
3333
Button {
3434
UIPasteboard.general.string = presence.user.id.uuidString
3535
} label: {
36-
Text("Copy User ID")
37-
Image(systemName: "doc.on.doc")
36+
Label("Copy User ID", systemImage: "doc.on.doc")
3837
}
3938
Button {
4039
UIPasteboard.general.string = presence.user.name
4140
} label: {
42-
Text("Copy User Name")
43-
Image(systemName: "doc.on.doc")
41+
Label("Copy User Name", systemImage: "doc.on.doc")
4442
}
4543
if !presence.info.isEmpty {
4644
Button {
4745
UIPasteboard.general.string = presence.info
4846
} label: {
49-
Text("Copy Status Info")
50-
Image(systemName: "doc.on.doc")
47+
Label("Copy Status Info", systemImage: "doc.on.doc")
5148
}
5249
}
5350
Button {
5451
navigation.open(channel: .dm([network.myId, presence.user.id]))
5552
} label: {
56-
Text("Open DM channel")
57-
Image(systemName: "at")
53+
Label("Open DM channel", systemImage: "at")
5854
}
5955
}
6056
}

0 commit comments

Comments
 (0)