-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #767 from 0x1-company/allow-access
feat: 🎸 create allow access
- Loading branch information
Showing
8 changed files
with
409 additions
and
0 deletions.
There are no files selected for viewing
153 changes: 153 additions & 0 deletions
153
Packages/GodPackage/Sources/OnboardFeature/AllowAccess.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
import AnalyticsClient | ||
import ComposableArchitecture | ||
import SwiftUI | ||
import Styleguide | ||
import UserNotificationClient | ||
import ContactsClient | ||
|
||
public struct AllowAccessLogic: Reducer { | ||
public init() {} | ||
|
||
public struct State: Equatable { | ||
var isDisabledContact = false | ||
var isDisabledNotify = false | ||
public init() {} | ||
} | ||
|
||
public enum Action: Equatable { | ||
case onTask | ||
case onAppear | ||
} | ||
|
||
@Dependency(\.contacts) var contacts | ||
@Dependency(\.analytics) var analytics | ||
@Dependency(\.userNotifications) var userNotifications | ||
|
||
public var body: some Reducer<State, Action> { | ||
Reduce<State, Action> { _, action in | ||
switch action { | ||
case .onTask: | ||
return .none | ||
|
||
case .onAppear: | ||
analytics.logScreen(screenName: "AllowAccess", of: self) | ||
return .none | ||
} | ||
} | ||
} | ||
} | ||
|
||
public struct AllowAccessView: View { | ||
let store: StoreOf<AllowAccessLogic> | ||
|
||
public init(store: StoreOf<AllowAccessLogic>) { | ||
self.store = store | ||
} | ||
|
||
public var body: some View { | ||
WithViewStore(store, observe: { $0 }) { viewStore in | ||
VStack { | ||
Spacer() | ||
|
||
VStack(spacing: 24) { | ||
Image(ImageResource.godIconWhite) | ||
.resizable() | ||
.aspectRatio(contentMode: .fit) | ||
.frame(width: 140) | ||
|
||
Text("God needs to find your school and suggest friends.", bundle: .module) | ||
.font(.system(.body, design: .rounded)) | ||
} | ||
|
||
Spacer() | ||
|
||
VStack(spacing: 8) { | ||
Button { | ||
|
||
} label: { | ||
HStack(spacing: 12) { | ||
Image(ImageResource.bell) | ||
.resizable() | ||
.aspectRatio(1, contentMode: .fit) | ||
.frame(width: 24, height: 24) | ||
Text("Enable Notify") | ||
} | ||
} | ||
.disabled(viewStore.isDisabledNotify) | ||
.buttonStyle(AllowButtonStyle(isDisabled: viewStore.isDisabledNotify)) | ||
|
||
Button { | ||
|
||
} label: { | ||
HStack(spacing: 12) { | ||
Image(ImageResource.ledger) | ||
.resizable() | ||
.aspectRatio(1, contentMode: .fit) | ||
.frame(width: 24, height: 24) | ||
Text("Enable Contacts") | ||
} | ||
} | ||
.disabled(viewStore.isDisabledContact) | ||
.buttonStyle(AllowButtonStyle(isDisabled: viewStore.isDisabledContact)) | ||
} | ||
|
||
Spacer() | ||
|
||
Spacer() | ||
|
||
HStack(spacing: 8) { | ||
Image(systemName: "lock.fill") | ||
.tint(Color.white) | ||
|
||
Text("God cares intensely about your privacy.\nWe will never text or spam your contacts.", bundle: .module) | ||
.multilineTextAlignment(.leading) | ||
} | ||
.font(.system(.callout, design: .rounded)) | ||
} | ||
.padding(.horizontal, 24) | ||
.foregroundStyle(Color.white) | ||
.background(Color.godService) | ||
.multilineTextAlignment(.center) | ||
.navigationTitle(Text("Please allow access", bundle: .module)) | ||
.navigationBarTitleDisplayMode(.inline) | ||
.toolbarBackground(Color.godService, for: .navigationBar) | ||
.toolbarBackground(.visible, for: .navigationBar) | ||
.toolbarColorScheme(.dark, for: .navigationBar) | ||
.task { await store.send(.onTask).finish() } | ||
.onAppear { store.send(.onAppear) } | ||
} | ||
} | ||
|
||
struct AllowButtonStyle: ButtonStyle { | ||
let isDisabled: Bool | ||
func makeBody(configuration: Configuration) -> some View { | ||
configuration.label | ||
.font(.system(.body, design: .rounded, weight: .bold)) | ||
.frame(height: 54) | ||
.frame(maxWidth: .infinity) | ||
.foregroundStyle(isDisabled ? Color.white : Color.black) | ||
.background(isDisabled ? Color.godService : Color.white) | ||
.clipShape(Capsule()) | ||
.scaleEffect(configuration.isPressed ? 0.9 : 1.0) | ||
.animation(.default, value: configuration.isPressed) | ||
.overlay { | ||
if isDisabled { | ||
RoundedRectangle(cornerRadius: 54 / 2) | ||
.stroke(Color.white, lineWidth: 1) | ||
} | ||
} | ||
.opacity(isDisabled ? 0.3 : 1.0) | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
NavigationStack { | ||
AllowAccessView( | ||
store: .init( | ||
initialState: AllowAccessLogic.State(), | ||
reducer: { AllowAccessLogic() } | ||
) | ||
) | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Packages/GodPackage/Sources/OnboardFeature/Assets.xcassets/bell.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "bell.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
Packages/GodPackage/Sources/OnboardFeature/Assets.xcassets/bell.imageset/bell.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
...s/GodPackage/Sources/OnboardFeature/Assets.xcassets/god-icon-white.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "god.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...dPackage/Sources/OnboardFeature/Assets.xcassets/god-icon-white.imageset/god.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
Packages/GodPackage/Sources/OnboardFeature/Assets.xcassets/ledger.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "ledger.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Oops, something went wrong.