feat: Introduce system accounts and verification badges
- Added SystemAccounts enum to manage system account keys and titles. - Refactored Dialog model to replace isVerified with verified level. - Implemented effective verification logic for UI display in Dialog. - Updated DialogRepository to handle user verification levels. - Enhanced ProtocolManager and SessionManager to log user info with verification. - Modified AuthCoordinator to support back navigation to unlock screen. - Improved UnlockView and WelcomeView with new account creation flow. - Added VerifiedBadge component to visually represent account verification levels. - Updated ChatListView and SearchView to display verification badges for users. - Cleaned up debug print statements across various components.
This commit is contained in:
41
Rosetta/DesignSystem/Components/GlassModifiers.swift
Normal file
41
Rosetta/DesignSystem/Components/GlassModifiers.swift
Normal file
@@ -0,0 +1,41 @@
|
||||
import SwiftUI
|
||||
|
||||
// MARK: - Glass Navigation Bar Modifier
|
||||
|
||||
/// Applies glassmorphism effect to the navigation bar on iOS 26+, falling back to ultra-thin material.
|
||||
struct GlassNavBarModifier: ViewModifier {
|
||||
func body(content: Content) -> some View {
|
||||
if #available(iOS 26, *) {
|
||||
content
|
||||
} else {
|
||||
content
|
||||
.toolbarBackground(.ultraThinMaterial, for: .navigationBar)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension View {
|
||||
func applyGlassNavBar() -> some View {
|
||||
modifier(GlassNavBarModifier())
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Glass Search Bar Modifier
|
||||
|
||||
/// Applies glassmorphism capsule effect on iOS 26+.
|
||||
struct GlassSearchBarModifier: ViewModifier {
|
||||
func body(content: Content) -> some View {
|
||||
if #available(iOS 26, *) {
|
||||
content
|
||||
.glassEffect(.regular, in: .capsule)
|
||||
} else {
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension View {
|
||||
func applyGlassSearchBar() -> some View {
|
||||
modifier(GlassSearchBarModifier())
|
||||
}
|
||||
}
|
||||
@@ -60,8 +60,7 @@ struct RosettaTabBar: View {
|
||||
searchPill
|
||||
}
|
||||
.padding(.horizontal, 25)
|
||||
.padding(.top, 16)
|
||||
.padding(.bottom, safeAreaBottom > 0 ? safeAreaBottom : 25)
|
||||
.padding(.top, 4)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
76
Rosetta/DesignSystem/Components/VerifiedBadge.swift
Normal file
76
Rosetta/DesignSystem/Components/VerifiedBadge.swift
Normal file
@@ -0,0 +1,76 @@
|
||||
import SwiftUI
|
||||
|
||||
// MARK: - VerifiedBadge
|
||||
|
||||
/// Displays a verified rosette badge for accounts with server-assigned verification.
|
||||
///
|
||||
/// Verification levels (from server `verified` field):
|
||||
/// - `0` — not verified (badge hidden)
|
||||
/// - `1` — public figure, brand, or organization
|
||||
/// - `2` — official Rosetta administration account
|
||||
/// - `3+` — group administrator
|
||||
///
|
||||
/// Tapping the badge presents a dialog explaining the verification level.
|
||||
struct VerifiedBadge: View {
|
||||
let verified: Int
|
||||
var size: CGFloat = 16
|
||||
var badgeTint: Color?
|
||||
|
||||
@Environment(\.colorScheme) private var colorScheme
|
||||
@State private var showExplanation = false
|
||||
|
||||
var body: some View {
|
||||
if verified > 0 {
|
||||
Image(systemName: "checkmark.seal.fill")
|
||||
.font(.system(size: size))
|
||||
.foregroundStyle(resolvedColor)
|
||||
.onTapGesture { showExplanation = true }
|
||||
.accessibilityLabel("Verified account")
|
||||
.alert("Verified Account", isPresented: $showExplanation) {
|
||||
Button("OK", role: .cancel) {}
|
||||
} message: {
|
||||
Text(annotationText)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private var resolvedColor: Color {
|
||||
if let badgeTint { return badgeTint }
|
||||
return colorScheme == .dark
|
||||
? RosettaColors.primaryBlue // #248AE6
|
||||
: Color(hex: 0xACD2F9) // soft blue (light theme)
|
||||
}
|
||||
|
||||
private var annotationText: String {
|
||||
switch verified {
|
||||
case 1:
|
||||
return "This is an official account belonging to a public figure, brand, or organization."
|
||||
case 2:
|
||||
return "This is an official account belonging to the administration of Rosetta."
|
||||
default:
|
||||
return "This user is an administrator of this group."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Preview
|
||||
|
||||
#Preview {
|
||||
VStack(spacing: 16) {
|
||||
HStack {
|
||||
Text("Level 1")
|
||||
VerifiedBadge(verified: 1, size: 16)
|
||||
}
|
||||
HStack {
|
||||
Text("Level 2")
|
||||
VerifiedBadge(verified: 2, size: 20)
|
||||
}
|
||||
HStack {
|
||||
Text("Not verified")
|
||||
VerifiedBadge(verified: 0, size: 16)
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
Reference in New Issue
Block a user