mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-25 14:12:27 +00:00
ui: channels preset tag (#6850)
This commit is contained in:
@@ -38,8 +38,9 @@ enum PresetTag: Int, Identifiable, CaseIterable, Equatable {
|
||||
case favorites = 1
|
||||
case contacts = 2
|
||||
case groups = 3
|
||||
case business = 4
|
||||
case notes = 5
|
||||
case channels = 4
|
||||
case business = 5
|
||||
case notes = 6
|
||||
|
||||
var id: Int { rawValue }
|
||||
|
||||
@@ -881,6 +882,7 @@ struct TagsView: View {
|
||||
case .favorites: (active ? "star.fill" : "star", "Favorites")
|
||||
case .contacts: (active ? "person.fill" : "person", "Contacts")
|
||||
case .groups: (active ? "person.2.fill" : "person.2", "Groups")
|
||||
case .channels: (active ? "antenna.radiowaves.left.and.right.circle.fill" : "antenna.radiowaves.left.and.right.circle", "Channels")
|
||||
case .business: (active ? "briefcase.fill" : "briefcase", "Businesses")
|
||||
case .notes: (active ? "folder.fill" : "folder", "Notes")
|
||||
}
|
||||
@@ -924,7 +926,12 @@ func presetTagMatchesChat(_ tag: PresetTag, _ chatInfo: ChatInfo, _ chatStats: C
|
||||
}
|
||||
case .groups:
|
||||
switch chatInfo {
|
||||
case let .group(groupInfo, _): groupInfo.businessChat == nil
|
||||
case let .group(groupInfo, _): groupInfo.businessChat == nil && !groupInfo.isChannel
|
||||
default: false
|
||||
}
|
||||
case .channels:
|
||||
switch chatInfo {
|
||||
case let .group(groupInfo, _): groupInfo.isChannel
|
||||
default: false
|
||||
}
|
||||
case .business:
|
||||
|
||||
@@ -2371,6 +2371,7 @@ public struct GroupInfo: Identifiable, Decodable, NamedChat, Hashable {
|
||||
public var ready: Bool { get { true } }
|
||||
public var nextConnectPrepared: Bool { if let preparedGroup { !preparedGroup.connLinkStartedConnection } else { false } }
|
||||
public var profileChangeProhibited: Bool { preparedGroup?.connLinkPreparedConnection ?? false }
|
||||
public var isChannel: Bool { groupProfile.isChannel }
|
||||
public var displayName: String { localAlias == "" ? groupProfile.displayName : localAlias }
|
||||
public var fullName: String { get { groupProfile.fullName } }
|
||||
public var shortDescr: String? { groupProfile.shortDescr }
|
||||
@@ -2499,6 +2500,8 @@ public struct GroupProfile: Codable, NamedChat, Hashable {
|
||||
set { memberAdmission = newValue }
|
||||
}
|
||||
|
||||
public var isChannel: Bool { publicGroup?.groupType == .channel }
|
||||
|
||||
public static let sampleData = GroupProfile(
|
||||
displayName: "team",
|
||||
fullName: "My Team"
|
||||
@@ -4864,10 +4867,7 @@ public enum MsgChatLink: Equatable, Hashable {
|
||||
public var iconName: String {
|
||||
switch self {
|
||||
case let .group(_, groupProfile):
|
||||
switch groupProfile.publicGroup?.groupType {
|
||||
case .channel: "antenna.radiowaves.left.and.right.circle.fill"
|
||||
case .unknown, .none: "person.2.circle.fill"
|
||||
}
|
||||
groupProfile.isChannel ? "antenna.radiowaves.left.and.right.circle.fill" : "person.2.circle.fill"
|
||||
case let .contact(_, _, business):
|
||||
business ? "briefcase.circle.fill" : "person.crop.circle.fill"
|
||||
case .invitation:
|
||||
@@ -4878,10 +4878,7 @@ public enum MsgChatLink: Equatable, Hashable {
|
||||
public var smallIconName: String {
|
||||
switch self {
|
||||
case let .group(_, groupProfile):
|
||||
switch groupProfile.publicGroup?.groupType {
|
||||
case .channel: "antenna.radiowaves.left.and.right"
|
||||
case .unknown, .none: "person.2"
|
||||
}
|
||||
groupProfile.isChannel ? "antenna.radiowaves.left.and.right" : "person.2"
|
||||
case let .contact(_, _, business):
|
||||
business ? "briefcase" : "person"
|
||||
case .invitation:
|
||||
@@ -4910,10 +4907,9 @@ public enum MsgChatLink: Equatable, Hashable {
|
||||
public func infoLine(signed: Bool) -> String {
|
||||
var s: String = switch self {
|
||||
case let .group(_, groupProfile):
|
||||
switch groupProfile.publicGroup?.groupType {
|
||||
case .channel: NSLocalizedString("Channel link", comment: "chat link info line")
|
||||
case .unknown, .none: NSLocalizedString("Group link", comment: "chat link info line")
|
||||
}
|
||||
groupProfile.isChannel
|
||||
? NSLocalizedString("Channel link", comment: "chat link info line")
|
||||
: NSLocalizedString("Group link", comment: "chat link info line")
|
||||
case let .contact(_, _, business):
|
||||
business
|
||||
? NSLocalizedString("Business address", comment: "chat link info line")
|
||||
|
||||
@@ -2094,6 +2094,7 @@ data class GroupInfo (
|
||||
ChatFeature.Calls -> false
|
||||
}
|
||||
override val timedMessagesTTL: Int? get() = with(fullGroupPreferences.timedMessages) { if (on) ttl else null }
|
||||
val isChannel: Boolean get() = groupProfile.isChannel
|
||||
override val displayName get() = localAlias.ifEmpty { groupProfile.displayName }
|
||||
override val fullName get() = groupProfile.fullName
|
||||
override val shortDescr get() = groupProfile.shortDescr
|
||||
@@ -2213,6 +2214,8 @@ data class GroupProfile (
|
||||
val groupPreferences: GroupPreferences? = null,
|
||||
val memberAdmission: GroupMemberAdmission? = null
|
||||
): NamedChat {
|
||||
val isChannel: Boolean get() = publicGroup?.groupType == GroupType.Channel
|
||||
|
||||
companion object {
|
||||
val sampleData = GroupProfile(
|
||||
displayName = "team",
|
||||
@@ -4594,30 +4597,21 @@ sealed class MsgChatLink {
|
||||
|
||||
val iconRes: ImageResource
|
||||
get() = when (this) {
|
||||
is Group -> when (groupProfile.publicGroup?.groupType) {
|
||||
GroupType.Channel -> MR.images.ic_bigtop_updates_circle_filled
|
||||
else -> MR.images.ic_supervised_user_circle_filled
|
||||
}
|
||||
is Group -> if (groupProfile.isChannel) MR.images.ic_bigtop_updates_circle_filled else MR.images.ic_supervised_user_circle_filled
|
||||
is Contact -> if (business) MR.images.ic_work_filled_padded else MR.images.ic_account_circle_filled
|
||||
is Invitation -> MR.images.ic_account_circle_filled
|
||||
}
|
||||
|
||||
val smallIconRes: ImageResource
|
||||
get() = when (this) {
|
||||
is Group -> when (groupProfile.publicGroup?.groupType) {
|
||||
GroupType.Channel -> MR.images.ic_bigtop_updates
|
||||
else -> MR.images.ic_group
|
||||
}
|
||||
is Group -> if (groupProfile.isChannel) MR.images.ic_bigtop_updates else MR.images.ic_group
|
||||
is Contact -> if (business) MR.images.ic_work else MR.images.ic_person
|
||||
is Invitation -> MR.images.ic_person
|
||||
}
|
||||
|
||||
fun infoLine(signed: Boolean): String {
|
||||
var s = when (this) {
|
||||
is Group -> when (groupProfile.publicGroup?.groupType) {
|
||||
GroupType.Channel -> generalGetString(MR.strings.chat_link_channel)
|
||||
else -> generalGetString(MR.strings.chat_link_group)
|
||||
}
|
||||
is Group -> if (groupProfile.isChannel) generalGetString(MR.strings.chat_link_channel) else generalGetString(MR.strings.chat_link_group)
|
||||
is Contact -> if (business) generalGetString(MR.strings.chat_link_business_address) else generalGetString(MR.strings.chat_link_contact_address)
|
||||
is Invitation -> generalGetString(MR.strings.chat_link_one_time)
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
enum class PresetTagKind { GROUP_REPORTS, FAVORITES, CONTACTS, GROUPS, BUSINESS, NOTES }
|
||||
enum class PresetTagKind { GROUP_REPORTS, FAVORITES, CONTACTS, GROUPS, CHANNELS, BUSINESS, NOTES }
|
||||
|
||||
sealed class ActiveFilter {
|
||||
data class PresetTag(val tag: PresetTagKind) : ActiveFilter()
|
||||
@@ -1236,7 +1236,11 @@ fun presetTagMatchesChat(tag: PresetTagKind, chatInfo: ChatInfo, chatStats: Chat
|
||||
else -> false
|
||||
}
|
||||
PresetTagKind.GROUPS -> when (chatInfo) {
|
||||
is ChatInfo.Group -> chatInfo.groupInfo.businessChat == null
|
||||
is ChatInfo.Group -> chatInfo.groupInfo.businessChat == null && !chatInfo.groupInfo.isChannel
|
||||
else -> false
|
||||
}
|
||||
PresetTagKind.CHANNELS -> when (chatInfo) {
|
||||
is ChatInfo.Group -> chatInfo.groupInfo.isChannel
|
||||
else -> false
|
||||
}
|
||||
PresetTagKind.BUSINESS -> when (chatInfo) {
|
||||
@@ -1255,6 +1259,7 @@ private fun presetTagLabel(tag: PresetTagKind, active: Boolean): Pair<ImageResou
|
||||
PresetTagKind.FAVORITES -> (if (active) MR.images.ic_star_filled else MR.images.ic_star) to MR.strings.chat_list_favorites
|
||||
PresetTagKind.CONTACTS -> (if (active) MR.images.ic_person_filled else MR.images.ic_person) to MR.strings.chat_list_contacts
|
||||
PresetTagKind.GROUPS -> (if (active) MR.images.ic_group_filled else MR.images.ic_group) to MR.strings.chat_list_groups
|
||||
PresetTagKind.CHANNELS -> (if (active) MR.images.ic_bigtop_updates_circle_filled else MR.images.ic_bigtop_updates) to MR.strings.chat_list_channels
|
||||
PresetTagKind.BUSINESS -> (if (active) MR.images.ic_work_filled else MR.images.ic_work) to MR.strings.chat_list_businesses
|
||||
PresetTagKind.NOTES -> (if (active) MR.images.ic_folder_closed_filled else MR.images.ic_folder_closed) to MR.strings.chat_list_notes
|
||||
}
|
||||
|
||||
@@ -497,6 +497,7 @@
|
||||
<string name="chat_list_favorites">Favorites</string>
|
||||
<string name="chat_list_contacts">Contacts</string>
|
||||
<string name="chat_list_groups">Groups</string>
|
||||
<string name="chat_list_channels">Channels</string>
|
||||
<string name="chat_list_businesses">Businesses</string>
|
||||
<string name="chat_list_notes">Notes</string>
|
||||
<string name="chat_list_group_reports">Reports</string>
|
||||
|
||||
Reference in New Issue
Block a user