Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated welcome screen to a newer style #360

Merged
merged 6 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion FiveCalls/FiveCalls/Dashboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct Dashboard: View {
}

Image(.fivecallsStars)
.accessibilityHidden(true)
}
.padding(.horizontal, 10)
.padding(.bottom, 10)
Expand All @@ -42,7 +43,8 @@ struct Dashboard: View {
.font(.system(size: 20))
.fontWeight(.semibold)
.padding(.horizontal, 10)

.accessibilityAddTraits(.isHeader)

IssuesList(store: store, selectedIssue: $selectedIssue, showAllIssues: $showAllIssues)
}
.navigationBarHidden(true)
Expand Down Expand Up @@ -99,6 +101,7 @@ struct MenuView: View {
}
} label: {
Image(.gear).renderingMode(.template).tint(Color.fivecallsDarkBlue)
.accessibilityLabel(Text(R.string.localizable.menuName))
}
.popoverTipIfApplicable(
title: Text(R.string.localizable.menuTipTitle()),
Expand Down
13 changes: 7 additions & 6 deletions FiveCalls/FiveCalls/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"choose-issue-subheading" = "More details about this issue will appear here";

// dashboard
"menu-name" = "Menu";
"menu-scheduled-reminders" = "Reminders";
"menu-your-impact" = "Your Impact";
"menu-about" = "About";
Expand Down Expand Up @@ -132,12 +133,12 @@
"subheading-message" = "You're making a difference! Calling is the most effective way to influence your representatives, and here's what you've achieved:";

// welcome
"welcome-page-1-title" = "Make your voice heard";
"welcome-page-1-message" = "Turn your passive participation into active resistance. Facebook likes and Twitter retweets can’t create the change you want to see. Calling your Government on the phone can.";
"welcome-page-2-title" = "Spend 5 minutes, make 5 calls.";
"welcome-page-2-message" = "Calling is the most effective way to influence your representative.";
"welcome-page-2-calls" = "Together we've made\n%@ calls";
"welcome-page-2-button-title" = "Get Started";
"welcome-section-1-title" = "Make your voice heard";
"welcome-section-1-message" = "Turn your passive participation into active resistance. Facebook likes and Twitter retweets can’t create the change you want to see. Calling your Government on the phone can.";
"welcome-section-2-title" = "Spend 5 minutes, make 5 calls";
"welcome-section-2-message" = "Calling is the most effective way to influence your representative.";
"welcome-section-3-calls" = "Together we've made\n%@ calls";
"welcome-button-title" = "Continue";

// done
"done-title" = "You called on **%@**";
Expand Down
6 changes: 6 additions & 0 deletions FiveCalls/FiveCalls/LocationHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ struct LocationHeader: View {
.padding(.trailing)
.padding(.leading, 7)
}
.accessibilityElement(children: .ignore)
.accessibilityLabel(Text("Your location is: \(location!.locationDisplay)"))
.accessibilityAddTraits(.isButton)
}

var unsetLocationView: some View {
Expand All @@ -71,6 +74,9 @@ struct LocationHeader: View {
.padding(.trailing)
.padding(.leading, 7)
}
.accessibilityElement(children: .ignore)
.accessibilityLabel(Text("Set your location"))
.accessibilityAddTraits(.isButton)
}
}

Expand Down
5 changes: 5 additions & 0 deletions FiveCalls/FiveCalls/LocationSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ struct LocationSheet: View {
.onTapGesture {
locationSearch()
}
.accessibilityHidden(true)
}
Text("Use an address, zip code or zip + 4")
.font(.footnote)
.foregroundColor(.secondary)
.padding(.leading, 35)
.accessibilityHidden(true)
}
.padding(.bottom)
HStack(alignment: .top) {
Expand Down Expand Up @@ -99,6 +101,9 @@ struct LocationSheet: View {
}
}
}
.accessibilityElement(children: .ignore)
.accessibilityLabel(Text("Detect my location"))
.accessibilityAddTraits(.isButton)
}
}

Expand Down
173 changes: 84 additions & 89 deletions FiveCalls/FiveCalls/Welcome.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,112 +9,107 @@
import SwiftUI

struct Welcome: View {
@EnvironmentObject var store: Store

var onContinue: (() -> Void)?

var body: some View {
VStack {
Image(.fivecallsLogotype)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 292)
.padding(.vertical, 24)
TabView {
Page1()
Page2(onContinue: onContinue)
}
.tabViewStyle(.page)
}
}
}

struct Welcome_Previews: PreviewProvider {
static let previewState = {
var state = AppState()
state.globalCallCount = 12345
return state
}()

static let previewStore = Store(state: previewState, middlewares: [appMiddleware()])

static var previews: some View {
Welcome().environmentObject(previewStore)
}
}

struct Page1: View {
var body: some View {
VStack(alignment: .leading, spacing: 20) {
Text(R.string.localizable.welcomePage1Title())
.font(.title)
.textCase(.uppercase)
.foregroundStyle(.fivecallsDarkBlueText)
Text(R.string.localizable.welcomePage1Message())
.font(.headline)
.foregroundStyle(.fivecallsDarkBlueText)
Spacer()
}
.padding(EdgeInsets(top: 24, leading: 24, bottom: 20, trailing: 24))
}
}

struct Page2: View {
@Environment(\.dismiss) var dismiss
@EnvironmentObject var store: Store

var onContinue: (() -> Void)?

var subMessage: String {
guard store.state.globalCallCount > 0 else {
return ""
}
return String(format: R.string.localizable.welcomePage2Calls(

return String(format: R.string.localizable.welcomeSection3Calls(
StatsViewModel(numberOfCalls: store.state.globalCallCount).formattedNumberOfCalls)
)
}

var subMessageOpacity: Double {
store.state.globalCallCount > 0 ? 1 : 0
}

var body: some View {
VStack(alignment: .leading, spacing: 10) {
Text(R.string.localizable.welcomePage2Title())
.font(.title)
.foregroundStyle(.fivecallsDarkBlueText)
Text(R.string.localizable.welcomePage2Message())
.font(.headline)
.foregroundStyle(.fivecallsDarkBlueText)
Text(subMessage)
.font(.headline)
.textCase(.uppercase)
.foregroundStyle(.fivecallsDarkBlueText)
.opacity(subMessageOpacity)
.animation(.easeIn, value: subMessageOpacity)
Spacer()
Button(action: {
onContinue?()
dismiss()
}) {
Text(R.string.localizable.welcomePage2ButtonTitle())
.fontWeight(.semibold)
.foregroundColor(.white)
.font(.system(size: 30))
}
.padding()
.frame(maxWidth: .infinity, minHeight: 73)
.background {
RoundedRectangle(cornerRadius: 6)
.foregroundColor(Color.fivecallsDarkBlue)
ScrollView {
Grid(verticalSpacing: 30) {
Image(decorative: R.image.fivecallsLogotype)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 292)
.padding(.vertical, 24)
GridRow() {
Image(systemName: "phone.badge.waveform")
.symbolRenderingMode(.palette)
.foregroundStyle(.red, .blue)
.font(.title)
.accessibilityHidden(true)
VStack(alignment: .leading) {
Text(R.string.localizable.welcomeSection1Title())
.fontWeight(.heavy)
Text(R.string.localizable.welcomeSection1Message())
}
.accessibilityElement(children: .combine)
}
GridRow() {
Image(systemName: "goforward.5")
.foregroundStyle(.blue)
.font(.title)
.accessibilityHidden(true)
VStack(alignment: .leading) {
Text(R.string.localizable.welcomeSection2Title())
.fontWeight(.heavy)
Text(R.string.localizable.welcomeSection2Message())
}
.accessibilityElement(children: .combine)
}
GridRow() {
Image(systemName: "person.2")
.opacity(subMessageOpacity)
.symbolRenderingMode(.palette)
.foregroundStyle(.blue, .red)
.font(.title)
.accessibilityHidden(true)
Text(subMessage)
.fontWeight(.heavy)
.opacity(subMessageOpacity)
.gridColumnAlignment(.leading)
}
Spacer()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need two spacers here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the welcome view to accommodate dynamic text, I wrapped it in a ScrollView. That changes how spacers work, and two spacers gives us good space / drops the button almost to the bottom with default text sizes and a modern phone. This is also why the button gets cut off a bit on the small phone.

Spacer()
Button(action: {
onContinue?()
dismiss()
}) {
Text(R.string.localizable.welcomeButtonTitle())
.foregroundColor(.white)
}
.padding()
.frame(maxWidth: .infinity)
.background {
RoundedRectangle(cornerRadius: 6)
.foregroundColor(.blue)
}
}
}
.padding(EdgeInsets(top: 24, leading: 24, bottom: 48, trailing: 24))
.onAppear() {
if store.state.globalCallCount == 0 {
store.dispatch(action: .FetchStats(nil))
.onAppear() {
if store.state.globalCallCount == 0 {
store.dispatch(action: .FetchStats(nil))
}
}
.frame(maxWidth: .infinity)
.padding(30)
}
}
}

struct Welcome_Previews: PreviewProvider {
static let previewState = {
var state = AppState()
state.globalCallCount = 12345
return state
}()

static let previewStore = Store(state: previewState, middlewares: [appMiddleware()])

static var previews: some View {
Welcome().environmentObject(previewStore)
}
}