Add first tips

This commit is contained in:
Marcin Czachurski 2023-10-21 09:44:40 +02:00
parent f3598a9940
commit 87951bc674
9 changed files with 210 additions and 1 deletions

View File

@ -11,6 +11,7 @@ import ClientKit
import EnvironmentKit
import WidgetKit
import SwiftData
import TipKit
@main
struct VernissageApp: App {
@ -108,6 +109,9 @@ struct VernissageApp: App {
UIPageControl.appearance().currentPageIndicatorTintColor = UIColor.white.withAlphaComponent(0.7)
UIPageControl.appearance().pageIndicatorTintColor = UIColor.white.withAlphaComponent(0.4)
// Configure TipKit.
try? Tips.configure([.displayFrequency(.daily), .datastoreLocation(.applicationDefault)])
// Set custom configurations for Nuke image/data loaders.
self.setImagePipelines()

View File

@ -8,6 +8,8 @@ import Foundation
import SwiftUI
import EnvironmentKit
import ServicesKit
import TipKit
import WidgetsKit
@MainActor
extension View {
@ -22,6 +24,7 @@ private struct NavigationMenuButtons: ViewModifier {
@Environment(RouterPath.self) var routerPath
@Environment(\.modelContext) private var modelContext
private let menuCustomizableTip = MenuCustomizableTip()
private let onViewModeIconTap: (MainView.ViewMode) -> Void
private let imageFontSize = 20.0
@ -102,6 +105,7 @@ private struct NavigationMenuButtons: ViewModifier {
.background(.ultraThinMaterial)
.clipShape(Circle())
}
.popoverTip(menuCustomizableTip, arrowEdge: .bottom)
} else {
HStack(alignment: .center) {
self.composeImageView()
@ -119,6 +123,7 @@ private struct NavigationMenuButtons: ViewModifier {
.background(.ultraThinMaterial)
.clipShape(Capsule())
}
.popoverTip(menuCustomizableTip, arrowEdge: .bottom)
}
}

View File

@ -11,6 +11,7 @@ import ClientKit
import ServicesKit
import EnvironmentKit
import WidgetsKit
import TipKit
@MainActor
struct HomeTimelineView: View {
@ -28,6 +29,7 @@ struct HomeTimelineView: View {
private let defaultLimit = 80
private let imagePrefetcher = ImagePrefetcher(destination: .diskCache)
private let timelineDoubleTapTip = TimelineDoubleTapTip()
var body: some View {
switch state {
@ -56,6 +58,8 @@ struct HomeTimelineView: View {
ZStack {
ScrollView {
LazyVStack(alignment: .center) {
TipView(timelineDoubleTapTip)
ForEach(self.statusViewModels, id: \.id) { item in
if self.shouldUpToDateBeVisible(statusId: item.id) {
self.upToDatePlaceholder()

View File

@ -11,6 +11,7 @@ import PixelfedKit
import ClientKit
import ServicesKit
import EnvironmentKit
import WidgetsKit
@MainActor
struct MainView: View {
@ -28,6 +29,8 @@ struct MainView: View {
}
}
private let mainNavigationTip = MainNavigationTip()
@Query(sort: \AccountData.acct, order: .forward) var dbAccounts: [AccountData]
public enum ViewMode: Int {
@ -179,6 +182,7 @@ struct MainView: View {
}
.frame(width: 150)
.foregroundColor(.mainTextColor)
.popoverTip(self.mainNavigationTip)
}
}
}

View File

@ -208,6 +208,9 @@ struct ImageRowItemAsync: View {
self.showThumbImage = true
HapticService.shared.fireHaptic(of: .buttonPress)
// Mark that user performed specific action.
TimelineDoubleTapTip().invalidate(reason: .actionPerformed)
// Mark favourite booleans used to show star in the timeline view.
self.statusViewModel.favourited = true
withAnimation(.default.delay(2.0)) {

View File

@ -1621,6 +1621,108 @@
}
}
}
},
"tip.mainNavigation.message" : {
"comment" : "Main navigation tip message.",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "You can customize the position of main naviagation menu in the app settings."
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Położenie głównego menu nawigacyjnego można dostosować w ustawieniach aplikacji."
}
}
}
},
"tip.mainNavigation.title" : {
"comment" : "Main navigation tip title.",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Menu position"
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Pozycja menu"
}
}
}
},
"tip.menuCustomizable.message" : {
"comment" : "Menu customizable tip message.",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "You can change default option in the menu by long press on the specific option."
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Domyślną opcję w menu można zmienić poprzez długie naciśnięcie określonej opcji."
}
}
}
},
"tip.menuCustomizable.title" : {
"comment" : "Menu customizable tip title.",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Changing the default options"
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Zmiana domyślnych opcji"
}
}
}
},
"tip.timelineDoubleTap.message" : {
"comment" : "Timeline double tip message.",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Double-tapping on a photo will result in it being favourited."
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Dwukrotne dotknięcie zdjęcia spowoduje jego polubienie."
}
}
}
},
"tip.timelineDoubleTap.title" : {
"comment" : "Timeline double tip title.",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Mark as favorite"
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Oznacz jako ulubione"
}
}
}
}
},
"version" : "1.0"

View File

@ -0,0 +1,29 @@
//
// https://mczachurski.dev
// Copyright © 2023 Marcin Czachurski and the repository contributors.
// Licensed under the Apache License 2.0.
//
import SwiftUI
import Foundation
import TipKit
public struct MainNavigationTip: Tip {
public var options: [TipOption] {
Tips.MaxDisplayCount(2)
}
public var title: Text {
Text("tip.mainNavigation.title", bundle: Bundle.module, comment: "Main navigation tip title.")
}
public var message: Text? {
Text("tip.mainNavigation.message", bundle: Bundle.module, comment: "Main navigation tip message.")
}
public var image: Image? {
Image(systemName: "info.circle")
}
public init() { }
}

View File

@ -0,0 +1,29 @@
//
// https://mczachurski.dev
// Copyright © 2023 Marcin Czachurski and the repository contributors.
// Licensed under the Apache License 2.0.
//
import SwiftUI
import Foundation
import TipKit
public struct MenuCustomizableTip: Tip {
public var options: [TipOption] {
Tips.MaxDisplayCount(2)
}
public var title: Text {
Text("tip.menuCustomizable.title", bundle: Bundle.module, comment: "Menu customizable tip title.")
}
public var message: Text? {
Text("tip.menuCustomizable.message", bundle: Bundle.module, comment: "Menu customizable tip message.")
}
public var image: Image? {
Image(systemName: "hand.tap")
}
public init() { }
}

View File

@ -0,0 +1,29 @@
//
// https://mczachurski.dev
// Copyright © 2023 Marcin Czachurski and the repository contributors.
// Licensed under the Apache License 2.0.
//
import SwiftUI
import Foundation
import TipKit
public struct TimelineDoubleTapTip: Tip {
public var options: [TipOption] {
Tips.MaxDisplayCount(5)
}
public var title: Text {
Text("tip.timelineDoubleTap.title", bundle: Bundle.module, comment: "Timeline double tip title.")
}
public var message: Text? {
Text("tip.timelineDoubleTap.message", bundle: Bundle.module, comment: "Timeline double tip message.")
}
public var image: Image? {
Image(systemName: "star")
}
public init() { }
}