Add tip in threads to inform users what trusted network means

Changelog-Added: Added tip in threads to inform users what trusted network means
Signed-off-by: Terry Yiu <git@tyiu.xyz>
This commit is contained in:
2025-06-04 00:14:34 -04:00
committed by Daniel D’Aquino
parent e65219ee3e
commit b3d9ee3fc0
8 changed files with 88 additions and 1 deletions

View File

@@ -10,6 +10,10 @@ import AVKit
import MediaPlayer
import EmojiPicker
#if canImport(TipKit)
import TipKit
#endif
struct ZapSheet {
let target: ZapTarget
let lnurl: String
@@ -705,6 +709,21 @@ struct ContentView: View {
damus_state.nostrNetwork.pool.register_handler(sub_id: sub_id, handler: home.handle_event)
damus_state.nostrNetwork.connect()
if #available(iOS 17, *) {
if damus_state.settings.developer_mode && damus_state.settings.reset_tips_on_launch {
do {
try Tips.resetDatastore()
} catch {
Log.error("Failed to reset tips datastore: %s", for: .tips, error.localizedDescription)
}
}
do {
try Tips.configure()
} catch {
Log.error("Failed to configure tips: %s", for: .tips, error.localizedDescription)
}
}
}
func music_changed(_ state: MusicState) {

View File

@@ -131,6 +131,9 @@ class UserSettingsStore: ObservableObject {
@Setting(key: "show_trusted_replies_first", default_value: true)
var show_trusted_replies_first: Bool
@Setting(key: "reset_tips_on_launch", default_value: false)
var reset_tips_on_launch: Bool
@Setting(key: "hide_nsfw_tagged_content", default_value: false)
var hide_nsfw_tagged_content: Bool

View File

@@ -21,6 +21,7 @@ enum LogCategory: String {
case damus_purple
case image_uploading
case video_coordination
case tips
}
/// Damus structured logger

View File

@@ -7,6 +7,7 @@
import SwiftUI
import SwipeActions
import TipKit
struct ChatroomThreadView: View {
@Environment(\.dismiss) var dismiss
@@ -159,6 +160,12 @@ struct ChatroomThreadView: View {
// MARK: - Children view - outside trusted network
if !untrusted_events.isEmpty {
if #available(iOS 17, *) {
TipView(TrustedNetworkRepliesTip.shared, arrowEdge: .bottom)
.padding(.top, 10)
.padding(.horizontal)
}
VStack(alignment: .leading, spacing: 0) {
// Track this section's position
Color.clear
@@ -184,6 +191,10 @@ struct ChatroomThreadView: View {
withAnimation {
untrusted_network_expanded.toggle()
if #available(iOS 17, *) {
TrustedNetworkRepliesTip.shared.invalidate(reason: .actionPerformed)
}
scroll_to_event(scroller: scroller, id: ChatroomThreadView.untrusted_network_section_id, delay: 0.1, animate: true, anchor: ChatroomThreadView.sticky_header_adjusted_anchor)
}
}) {

View File

@@ -7,6 +7,10 @@
import SwiftUI
#if canImport(TipKit)
import TipKit
#endif
class NotificationFilter: ObservableObject, Equatable {
@Published var state: NotificationFilterState
@Published var friend_filter: FriendFilter
@@ -75,7 +79,9 @@ struct NotificationsView: View {
@StateObject var filter = NotificationFilter()
@SceneStorage("NotificationsView.filter_state") var filter_state: NotificationFilterState = .all
@Binding var subtitle: String?
@State var showTip: Bool = true
@Environment(\.colorScheme) var colorScheme
var body: some View {

View File

@@ -96,6 +96,11 @@ struct DeveloperSettingsView: View {
Toggle(NSLocalizedString("Enable experimental Purple In-app purchase support", comment: "Developer mode setting to enable experimental Purple In-app purchase support."), isOn: $settings.enable_experimental_purple_iap_support)
.toggleStyle(.switch)
if #available(iOS 17, *) {
Toggle(NSLocalizedString("Reset tips on launch", comment: "Developer mode setting to reset tips upon app first launch. Tips are visual contextual hints that highlight new, interesting, or unused features users have not discovered yet."), isOn: $settings.reset_tips_on_launch)
.toggleStyle(.switch)
}
}
}
}

View File

@@ -0,0 +1,26 @@
//
// TrustedNetworkRepliesTip.swift
// damus
//
// Created by Terry Yiu on 6/7/25.
//
import Foundation
import TipKit
@available(iOS 17, *)
struct TrustedNetworkRepliesTip: Tip {
static let shared = TrustedNetworkRepliesTip()
var title: Text {
Text("Toggle visibility of replies from outside your trusted network", comment: "Title of tip that informs users what trusted network means and that they can toggle the visibility of threaded replies from outside their trusted network.")
}
var message: Text? {
Text("Your trusted network is comprised of profiles you follow and profiles that they follow.", comment: "Description of the tip that informs users what trusted network means.")
}
var image: Image? {
Image(systemName: "network.badge.shield.half.filled")
}
}