Skip to content

Commit

Permalink
This version includes a change in the name of the mesot and minor mod…
Browse files Browse the repository at this point in the history
…ifications to the display.
  • Loading branch information
KC-2001MS committed Dec 30, 2023
1 parent d01ec38 commit aee03ab
Show file tree
Hide file tree
Showing 16 changed files with 60 additions and 43 deletions.
8 changes: 4 additions & 4 deletions .Sample/Sample/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,19 @@ struct ContentView: View {
.navigationTitle("OnboardingUI")
.formStyle(.grouped)
}
.sheet(isPresented: $appVersionManager.isTheFirstActivation) {
.sheet(isPresented: $appVersionManager.isTheFirstLaunch) {
WelcomeOnboardingSheetView(action: {
appVersionManager.isTheFirstActivation = false
appVersionManager.isTheFirstLaunch = false
})
}
.sheet(isPresented: $appVersionManager.isMajorVersionUpdated) {
NewFeatureOnboardingSheetView(action: {
appVersionManager.isMajorVersionUpdated = false
})
}
.sheet(isPresented: $appVersionManager.isMinorOrPatchVersionUpdated) {
.sheet(isPresented: $appVersionManager.isMajorOrMinorVersionUpdated) {
NewFeatureOnboardingSheetView(action: {
appVersionManager.isMinorOrPatchVersionUpdated = false
appVersionManager.isMajorOrMinorVersionUpdated = false
})
}
.onboardingSheet(isPresented: $isOpenSheet, WelcomeOnboarding())
Expand Down
2 changes: 1 addition & 1 deletion .Sample/Sample/Onboardings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct WhatIsNewOnboarding: Onboarding {
var features: Array<Feature> {
Feature(
"New AppVersionManager environment variable" ,
imageName: "wrench.and.screwdriver",
imageName: "tree",
message: "The new AppVersionManager environment variable allows you to display onboarding at the intended time."
)

Expand Down
2 changes: 1 addition & 1 deletion .Sample/Sample/UI/NewFeatureOnboardingSheetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct NewFeatureOnboardingSheetView: View {
OnboardingSheetView {
OnboardingTitle("What's New in\nOnboardingUI")
} content: {
OnboardingItem(systemName: "wrench.and.screwdriver",shape: .red) {
OnboardingItem(systemName: "tree",shape: .green) {
OnboardingSubtitle("New AppVersionManager environment variable")
OnboardingContent("The new AppVersionManager environment variable allows you to display onboarding at the intended time.")
}
Expand Down
2 changes: 2 additions & 0 deletions .Sample/Sample/UI/WelcomeOnboardingSheetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ struct WelcomeOnboardingSheetView: View {
OnboardingSubtitle("Customize SF Symbols")
OnboardingContent("When using a highly customizable implementation method, multi-color and SF symbol hierarchies are supported and can be freely customized.")
}
} link: {
Link("Check our Privacy Policy…", destination: URL(string: "https://kc-2001ms.github.io/en/privacy.html")!)
} button: {
ContinueButton(color: .accentColor, action: action)
}
Expand Down
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct SimpleImplementationView: View {
var body: some View {
@Bindable var appVersionManager = appVersionManager
SomeView()
.sheetOnboarding(isPresented: $appVersionManager.isTheFirstActivation, WelcomeOnboarding())
.onboardingSheet(isPresented: $appVersionManager.isTheFirstLaunch, WelcomeOnboarding())
}
}
```
Expand Down Expand Up @@ -128,7 +128,7 @@ struct WelcomeOnboardingSheetView: View {
}

var body: some View {
OnboardingSheet {
OnboardingSheetView {
OnboardingTitle("Welcome to\nOnboardingUI")
} content: {
OnboardingItem(systemName: "applescript",shape: .red) {
Expand All @@ -143,17 +143,15 @@ struct WelcomeOnboardingSheetView: View {

OnboardingItem(systemName: "circle.badge.checkmark",mode: .palette,primary: .primary,secondary: .blue) {
OnboardingSubtitle("Customize SF Symbols")
OnboardingContent("When using a highly customizable implementation method, multi-color and SF symbol hierarchies are supported and can be freely customized. However, this feature is not supported in visionOS.")
OnboardingContent("When using a highly customizable implementation method, multi-color and SF symbol hierarchies are supported and can be freely customized.")
}
} link: {
Link("Check our Privacy Policy…", destination: URL(string: "https://kc-2001ms.github.io/en/privacy.html")!)
} button: {
ContinueButton(color: .accentColor, action: action)
}
}
}

#Preview {
WelcomeOnboardingSheetView(action: {})
}
```

and
Expand All @@ -165,9 +163,9 @@ struct SimpleImplementationView: View {
var body: some View {
@Bindable var appVersionManager = appVersionManager
SomeView()
.sheet(isPresented: $appVersionManager.isTheFirstActivation) {
.sheet(isPresented: $appVersionManager.isTheFirstLaunch) {
WelcomeOnboardingSheetView(action: {
appVersionManager.isTheFirstActivation = false
appVersionManager.isTheFirstLaunch = false
})
}
}
Expand Down
23 changes: 4 additions & 19 deletions Sources/OnboardingUI/Processing/AppVersionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class AppVersionManager {
}
}
/// Whether or not this is the first activation.
public var isTheFirstActivation: Bool {
public var isTheFirstLaunch: Bool {
get {
return lastOpenedVersion == ""
}
Expand All @@ -45,13 +45,12 @@ public class AppVersionManager {
}
}
/// Variable to detect if the minor version number or higher has increased.
public var isMinorOrPatchVersionUpdated: Bool {
public var isMajorOrMinorVersionUpdated: Bool {
get {
let lastOpenedComponents = filled(splitByDot(lastOpenedVersion), count: 3)
let currentComponents = filled(splitByDot(version), count: 3)
return lastOpenedComponents[0] == currentComponents[0] &&
(lastOpenedComponents[1] < currentComponents[1] ||
(lastOpenedComponents[1] == currentComponents[1] && lastOpenedComponents[2] < currentComponents[2]))
return (lastOpenedComponents[0] < currentComponents[0] && lastOpenedComponents[1] <= currentComponents[1]) ||
(lastOpenedComponents[0] <= currentComponents[0] && lastOpenedComponents[1] < currentComponents[1])
}

set {
Expand All @@ -77,17 +76,3 @@ public extension EnvironmentValues {
set { self[AppVersionManagerKey.self] = newValue }
}
}
/// Function to split the version number dot by dot
@available(iOS 17.0,macOS 14.0,watchOS 10.0,tvOS 17.0,visionOS 1.0,*)
func splitByDot(_ versionNumber: String) -> [Int] {
return versionNumber.split(separator: ".").map { string -> Int in
return Int(string) ?? 0
}
}
/// Function to unify the number of elements in an array
@available(iOS 17.0,macOS 14.0,watchOS 10.0,tvOS 17.0,visionOS 1.0,*)
func filled(_ target: [Int], count: Int) -> [Int] {
return (0..<count).map { i -> Int in
(i < target.count) ? target[i] : 0
}
}
24 changes: 24 additions & 0 deletions Sources/OnboardingUI/Processing/Functions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Functions.swift
//
//
// Created by Keisuke Chinone on 2023/12/30.
//


import Foundation

/// Function to split the version number dot by dot
@available(iOS 17.0,macOS 14.0,watchOS 10.0,tvOS 17.0,visionOS 1.0,*)
func splitByDot(_ versionNumber: String) -> [Int] {
return versionNumber.split(separator: ".").map { string -> Int in
return Int(string) ?? 0
}
}
/// Function to unify the number of elements in an array
@available(iOS 17.0,macOS 14.0,watchOS 10.0,tvOS 17.0,visionOS 1.0,*)
func filled(_ target: [Int], count: Int) -> [Int] {
return (0..<count).map { i -> Int in
(i < target.count) ? target[i] : 0
}
}
26 changes: 17 additions & 9 deletions Sources/OnboardingUI/UI/View/OnboardingSheetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public struct OnboardingSheetView<V1: View,V2: View,V3: View,V4: View>: View {
var title: V1
/// View displaying features
var content: V2

/// Link View
var link: V3
/// Button view at the bottom
var button: V4
Expand Down Expand Up @@ -71,19 +71,27 @@ public struct OnboardingSheetView<V1: View,V2: View,V3: View,V4: View>: View {
#else
.frame(maxWidth: .infinity)
#endif
if dynamicTypeSize > .xxxLarge {
link

button
VStack {
if dynamicTypeSize > .xxxLarge {
link
#if os(macOS)
.padding(30)
#else
.padding(.vertical, 5)
#endif

button
#if os(iOS)
.padding(.bottom, 70 - geom.size.height/15 + geom.size.height/20)
.padding(.top, 10)
.padding(.bottom, 70 - geom.size.height/15 + geom.size.height/20)
#elseif os(visionOS)
.padding(.bottom, geom.size.height/25)
.padding(.bottom, geom.size.height/25)
#elseif os(macOS)
.padding(.bottom, 15 + geom.size.height/20)
.padding(.bottom, 15 + geom.size.height/20)
#else
.padding(.bottom, geom.size.height/20)
.padding(.bottom, geom.size.height/20)
#endif
}
}
}
#if os(visionOS)
Expand Down
Binary file modified images/iOS_CustomizableImplementation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/iOS_SimpleImplementation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/iPadOS_CustomizableImplementation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/iPadOS_SimpleImplementation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/macOS_CustomizableImplementation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/macOS_SimpleImplementation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/tvOS_CustomizableImplementation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/tvOS_SimpleImplementation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit aee03ab

Please sign in to comment.