Skip to content

Commit

Permalink
Minor improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
bullinnyc committed Jul 2, 2023
1 parent e5eea45 commit 7d69507
Show file tree
Hide file tree
Showing 16 changed files with 177 additions and 99 deletions.
13 changes: 8 additions & 5 deletions Examples/ExampleArtLetterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import MagicText

struct ExampleArtLetterView: View {
// MARK: - Private Properties

private let singleLineExampleText = "Life is like a box of chocolates, you never know what you’re gonna get."

private let multiLineExampleText = """
Expand All @@ -22,18 +23,19 @@ struct ExampleArtLetterView: View {
"""

private let colors = [
candy, coffee, flower, forest, newyork,
night, sky, smoke, theia, venus
RM.candy, RM.coffee, RM.flower, RM.forest, RM.newyork,
RM.night, RM.sky, RM.smoke, RM.theia, RM.venus
]

// MARK: - body Property
// MARK: - Body Property

var body: some View {
VStack(spacing: 25) {
// Art letter magic text.
MagicView(
text: singleLineExampleText,
textColors: [.black.opacity(0.7)],
fontSize: 25,
fontSize: 28,
magicType: .artLetter
) {
print("Animation finished")
Expand All @@ -44,7 +46,7 @@ struct ExampleArtLetterView: View {
MagicView(
text: multiLineExampleText,
textColors: colors.map { Color($0) },
fontSize: 25,
fontSize: 28,
magicType: .artLetter,
delayStart: 5
) {
Expand All @@ -55,6 +57,7 @@ struct ExampleArtLetterView: View {
}

// MARK: - Preview Provider

struct ExampleArtLetterView_Previews: PreviewProvider {
static var previews: some View {
ExampleArtLetterView()
Expand Down
13 changes: 8 additions & 5 deletions Examples/ExampleBubbleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import MagicText

struct ExampleBubbleView: View {
// MARK: - Private Properties

private let singleLineExampleText = "Life is like a box of chocolates, you never know what you’re gonna get."

private let multiLineExampleText = """
Expand All @@ -22,18 +23,19 @@ struct ExampleBubbleView: View {
"""

private let colors = [
candy, coffee, flower, forest, newyork,
night, sky, smoke, theia, venus
RM.candy, RM.coffee, RM.flower, RM.forest, RM.newyork,
RM.night, RM.sky, RM.smoke, RM.theia, RM.venus
]

// MARK: - body Property
// MARK: - Body Property

var body: some View {
VStack(spacing: 25) {
// Bubble magic text.
MagicView(
text: singleLineExampleText,
textColors: [.black.opacity(0.7)],
fontSize: 30,
fontSize: 28,
magicType: .bubble
) {
print("Animation finished")
Expand All @@ -44,7 +46,7 @@ struct ExampleBubbleView: View {
MagicView(
text: multiLineExampleText,
textColors: colors.map { Color($0) },
fontSize: 30,
fontSize: 28,
magicType: .bubble,
delayStart: 5
) {
Expand All @@ -55,6 +57,7 @@ struct ExampleBubbleView: View {
}

// MARK: - Preview Provider

struct ExampleBubbleView_Previews: PreviewProvider {
static var previews: some View {
ExampleBubbleView()
Expand Down
13 changes: 8 additions & 5 deletions Examples/ExampleCharmedLetterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import MagicText

struct ExampleCharmedLetterView: View {
// MARK: - Private Properties

private let singleLineExampleText = "Life is like a box of chocolates, you never know what you’re gonna get."

private let multiLineExampleText = """
Expand All @@ -22,18 +23,19 @@ struct ExampleCharmedLetterView: View {
"""

private let colors = [
candy, coffee, flower, forest, newyork,
night, sky, smoke, theia, venus
RM.candy, RM.coffee, RM.flower, RM.forest, RM.newyork,
RM.night, RM.sky, RM.smoke, RM.theia, RM.venus
]

// MARK: - body Property
// MARK: - Body Property

var body: some View {
VStack(spacing: 25) {
// Charmed letter magic text.
MagicView(
text: singleLineExampleText,
textColors: [.black.opacity(0.7)],
fontSize: 30,
fontSize: 28,
magicType: .charmedLetter()
) {
print("Animation finished")
Expand All @@ -44,7 +46,7 @@ struct ExampleCharmedLetterView: View {
MagicView(
text: multiLineExampleText,
textColors: colors.map { Color($0) },
fontSize: 30,
fontSize: 28,
magicType: .charmedLetter(backgroundColor: .blue),
delayStart: 5
) {
Expand All @@ -55,6 +57,7 @@ struct ExampleCharmedLetterView: View {
}

// MARK: - Preview Provider

struct ExampleCharmedLetterView_Previews: PreviewProvider {
static var previews: some View {
ExampleCharmedLetterView()
Expand Down
12 changes: 7 additions & 5 deletions Examples/ExampleCharmedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import MagicText

struct ExampleCharmedView: View {
// MARK: - Private Properties

private let singleLineExampleText = "Life is like a box of chocolates, you never know what you’re gonna get."

private let multiLineExampleText = """
Expand All @@ -22,17 +23,18 @@ struct ExampleCharmedView: View {
"""

private let colors = [
candy, coffee, flower, forest, newyork,
night, sky, smoke, theia, venus
RM.candy, RM.coffee, RM.flower, RM.forest, RM.newyork,
RM.night, RM.sky, RM.smoke, RM.theia, RM.venus
]

// MARK: - body Property
// MARK: - Body Property

var body: some View {
VStack(spacing: 25) {
// Charmed magic text (default).
MagicView(
text: singleLineExampleText,
fontSize: 30
fontSize: 28
) {
print("Animation finished")
}
Expand All @@ -42,7 +44,7 @@ struct ExampleCharmedView: View {
MagicView(
text: multiLineExampleText,
textColors: [.black, .red, .orange, .yellow, .green, .blue],
fontSize: 30,
fontSize: 28,
delayStart: 5
) {
print("Animation finished")
Expand Down
13 changes: 8 additions & 5 deletions Examples/ExampleFantasyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import MagicText

struct ExampleFantasyView: View {
// MARK: - Private Properties

private let singleLineExampleText = "Life is like a box of chocolates, you never know what you’re gonna get."

private let multiLineExampleText = """
Expand All @@ -22,18 +23,19 @@ struct ExampleFantasyView: View {
"""

private let colors = [
candy, coffee, flower, forest, newyork,
night, sky, smoke, theia, venus
RM.candy, RM.coffee, RM.flower, RM.forest, RM.newyork,
RM.night, RM.sky, RM.smoke, RM.theia, RM.venus
]

// MARK: - body Property
// MARK: - Body Property

var body: some View {
VStack(spacing: 25) {
// Fantasy magic text.
MagicView(
text: singleLineExampleText,
textColors: [.black.opacity(0.7)],
fontSize: 30,
fontSize: 28,
magicType: .fantasy
) {
print("Animation finished")
Expand All @@ -44,7 +46,7 @@ struct ExampleFantasyView: View {
MagicView(
text: multiLineExampleText,
textColors: colors.map { Color($0) },
fontSize: 30,
fontSize: 28,
magicType: .fantasy,
delayStart: 5
) {
Expand All @@ -55,6 +57,7 @@ struct ExampleFantasyView: View {
}

// MARK: - Preview Provider

struct ExampleFantasyView_Previews: PreviewProvider {
static var previews: some View {
ExampleFantasyView()
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Magic text is the perfect solution when you need to show a small amount of infor
## Installation
### [Swift Package Manager](https://swift.org/package-manager/)

Going to Xcode `File` > `Add Packages...` and add the repository by giving the URL `https://github.com/bullinnyc/MagicText`
Going to Xcode `File` > `Add Packages...` and add the repository by giving the URL `https://github.com/bullinnyc/MagicText`
Enjoy!

## Usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,34 @@ struct AnimationCompletionAnimatableModifier<Value>:
AnimatableModifier where Value: VectorArithmetic
{
// MARK: - Animatable Protocol Properties

var animatableData: Value {
didSet {
notifyCompletionIfFinished()
}
}

// MARK: - Private Properties

private let targetValue: Value
private let completion: () -> Void

// MARK: - Initializers

init(value: Value, completion: @escaping () -> Void) {
self.completion = completion
animatableData = value
targetValue = value
}

// MARK: - body Method
// MARK: - Body Method

func body(content: Content) -> some View {
content
}

// MARK: - Private Methods

private func notifyCompletionIfFinished() {
guard animatableData == targetValue else { return }

Expand All @@ -45,6 +50,7 @@ struct AnimationCompletionAnimatableModifier<Value>:
}

// MARK: - Ext. View

extension View {
func onAnimationCompleted<Value: VectorArithmetic>(
value: Value,
Expand Down
Loading

0 comments on commit 7d69507

Please sign in to comment.