onboarding: Suggest first post during onboarding
Testing of standard flow ------------------------ PASS Device: iPhone 14 Pro simulator iOS: 17.0 Damus: This commit Steps: 1. Delete and reinstall Damus 2. Go through onboarding until suggested users appear 3. Click "continue". Should slide into the post view. PASS 4. Post view should look similar to the Figma design file, but with examples as placeholders. PASS 5. Examples should switch every 3 seconds. PASS 6. Typing a first character causes the #introductions hashtag to be automatically added. PASS 7. Uploading an image makes progress view show up and not break layout. PASS 8. Clicking on "post" should post this note and dismiss onboarding view. PASS Testing of other flows ---------------------- PASS Device: iPhone 14 Pro simulator iOS: 17.0 Damus: This commit Special remark: Made local change to always show the onboarding suggestions, and speed up testing Coverage: 1. Clicking "skip" on suggested users view will skip into the post view. PASS 2. Clicking "cancel" on post view and then going to the normal post view reveals a blank draft. PASS 3. Clicking "cancel" dismisses onboarding view and does not post anything. PASS 4. Normal post view looks normal (not broken). PASS 5. Changing initial suggested post during onboarding, cancelling the post, and then re-entering normal post view reveals the draft with user modifications. PASS Changelog-Added: Suggest first post during onboarding Closes: https://github.com/damus-io/damus/issues/1338 Signed-off-by: Daniel D’Aquino <daniel@daquino.me> Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
committed by
William Casarin
parent
7c98489904
commit
bf43842590
123
damus/Views/Onboarding/OnboardingSuggestionsView.swift
Normal file
123
damus/Views/Onboarding/OnboardingSuggestionsView.swift
Normal file
@@ -0,0 +1,123 @@
|
||||
//
|
||||
// OnboardingSuggestionsView.swift
|
||||
// damus
|
||||
//
|
||||
// Created by klabo on 7/17/23.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
fileprivate let first_post_example_1: String = NSLocalizedString("Hello everybody!\n\nThis is my first post on Damus, I am happy to meet you all 🤙. What’s up?\n\n#introductions", comment: "First post example given to the user during onboarding, as a suggestion as to what they could post first")
|
||||
fileprivate let first_post_example_2: String = NSLocalizedString("This is my first post on Nostr 💜. I love drawing and folding Origami!\n\nNice to meet you all! #introductions #plebchain ", comment: "First post example given to the user during onboarding, as a suggestion as to what they could post first")
|
||||
fileprivate let first_post_example_3: String = NSLocalizedString("For #Introductions! I’m a software developer.\n\nMy side interests include languages and I am striving to be a #polyglot - I am a native English speaker and can speak French, German and Japanese.", comment: "First post example given to the user during onboarding, as a suggestion as to what they could post first")
|
||||
fileprivate let first_post_example_4: String = NSLocalizedString("Howdy! I’m a graphic designer during the day and coder at night, but I’m also trying to spend more time outdoors.\n\nHope to meet folks who are on their own journeys to a peaceful and free life!", comment: "First post example given to the user during onboarding, as a suggestion as to what they could post first")
|
||||
|
||||
struct OnboardingSuggestionsView: View {
|
||||
|
||||
@StateObject var model: SuggestedUsersViewModel
|
||||
@State var current_page: Int = 0
|
||||
let first_post_examples: [String] = [first_post_example_1, first_post_example_2, first_post_example_3, first_post_example_4]
|
||||
let initial_text_suffix: String = "\n\n#introductions"
|
||||
|
||||
@Environment(\.presentationMode) private var presentationMode
|
||||
|
||||
func next_page() {
|
||||
withAnimation {
|
||||
current_page += 1
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
TabView(selection: $current_page) {
|
||||
SuggestedUsersPageView(model: model, next_page: self.next_page)
|
||||
.navigationTitle(NSLocalizedString("Who to Follow", comment: "Title for a screen displaying suggestions of who to follow"))
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.navigationBarItems(leading: Button(action: {
|
||||
self.next_page()
|
||||
}, label: {
|
||||
Text(NSLocalizedString("Skip", comment: "Button to dismiss the suggested users screen"))
|
||||
.font(.subheadline.weight(.semibold))
|
||||
}))
|
||||
.tag(0)
|
||||
|
||||
PostView(
|
||||
action: .posting(.user(model.damus_state.pubkey)),
|
||||
damus_state: model.damus_state,
|
||||
prompt_view: {
|
||||
AnyView(
|
||||
HStack {
|
||||
Image(systemName: "sparkles")
|
||||
Text(NSLocalizedString("Add your first post", comment: "Prompt given to the user during onboarding, suggesting them to write their first post"))
|
||||
}
|
||||
.foregroundColor(.secondary)
|
||||
.font(.callout)
|
||||
.padding(.top, 10)
|
||||
)
|
||||
},
|
||||
placeholder_messages: self.first_post_examples,
|
||||
initial_text_suffix: self.initial_text_suffix
|
||||
)
|
||||
.tag(1)
|
||||
}
|
||||
.tabViewStyle(.page(indexDisplayMode: .never))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate struct SuggestedUsersPageView: View {
|
||||
var model: SuggestedUsersViewModel
|
||||
var next_page: (() -> Void)
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
List {
|
||||
ForEach(model.groups) { group in
|
||||
Section {
|
||||
ForEach(group.users, id: \.self) { pk in
|
||||
if let user = model.suggestedUser(pubkey: pk) {
|
||||
SuggestedUserView(user: user, damus_state: model.damus_state)
|
||||
}
|
||||
}
|
||||
} header: {
|
||||
SuggestedUsersSectionHeader(group: group, model: model)
|
||||
}
|
||||
}
|
||||
}
|
||||
.listStyle(.plain)
|
||||
|
||||
Spacer()
|
||||
|
||||
Button(action: {
|
||||
self.next_page()
|
||||
}) {
|
||||
Text(NSLocalizedString("Continue", comment: "Button to dismiss suggested users view and continue to the main app"))
|
||||
.frame(minWidth: 300, maxWidth: .infinity, alignment: .center)
|
||||
}
|
||||
.buttonStyle(GradientButtonStyle())
|
||||
.padding([.leading, .trailing], 24)
|
||||
.padding(.bottom, 16)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SuggestedUsersSectionHeader: View {
|
||||
let group: SuggestedUserGroup
|
||||
let model: SuggestedUsersViewModel
|
||||
var body: some View {
|
||||
HStack {
|
||||
Text(group.title.uppercased())
|
||||
Spacer()
|
||||
Button(NSLocalizedString("Follow All", comment: "Button to follow all users in this section")) {
|
||||
model.follow(pubkeys: group.users)
|
||||
}
|
||||
.font(.subheadline.weight(.semibold))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SuggestedUsersView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
OnboardingSuggestionsView(model: SuggestedUsersViewModel(damus_state: test_damus_state))
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
//
|
||||
// SuggestedUsersView.swift
|
||||
// damus
|
||||
//
|
||||
// Created by klabo on 7/17/23.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SuggestedUsersView: View {
|
||||
|
||||
@StateObject var model: SuggestedUsersViewModel
|
||||
|
||||
@Environment(\.presentationMode) private var presentationMode
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
VStack {
|
||||
List {
|
||||
ForEach(model.groups) { group in
|
||||
Section {
|
||||
ForEach(group.users, id: \.self) { pk in
|
||||
if let user = model.suggestedUser(pubkey: pk) {
|
||||
SuggestedUserView(user: user, damus_state: model.damus_state)
|
||||
}
|
||||
}
|
||||
} header: {
|
||||
SuggestedUsersSectionHeader(group: group, model: model)
|
||||
}
|
||||
}
|
||||
}
|
||||
.listStyle(.plain)
|
||||
|
||||
Spacer()
|
||||
|
||||
Button(action: {
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
}) {
|
||||
Text(NSLocalizedString("Continue", comment: "Button to dismiss suggested users view and continue to the main app"))
|
||||
.frame(minWidth: 300, maxWidth: .infinity, alignment: .center)
|
||||
}
|
||||
.buttonStyle(GradientButtonStyle())
|
||||
.padding([.leading, .trailing], 24)
|
||||
.padding(.bottom, 16)
|
||||
}
|
||||
.navigationTitle(NSLocalizedString("Who to Follow", comment: "Title for a screen displaying suggestions of who to follow"))
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.navigationBarItems(trailing: Button(action: {
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
}, label: {
|
||||
Text(NSLocalizedString("Skip", comment: "Button to dismiss the suggested users screen"))
|
||||
.font(.subheadline.weight(.semibold))
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SuggestedUsersSectionHeader: View {
|
||||
let group: SuggestedUserGroup
|
||||
let model: SuggestedUsersViewModel
|
||||
var body: some View {
|
||||
HStack {
|
||||
Text(group.title.uppercased())
|
||||
Spacer()
|
||||
Button(NSLocalizedString("Follow All", comment: "Button to follow all users in this section")) {
|
||||
model.follow(pubkeys: group.users)
|
||||
}
|
||||
.font(.subheadline.weight(.semibold))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SuggestedUsersView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
SuggestedUsersView(model: SuggestedUsersViewModel(damus_state: test_damus_state))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user