-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added initial iteration of the startup themepicker * added an onappear animation * fixed bug where the cells would refresh everytime a new theme was picked and also since the timer was still active at setup * used an offwhite color as the initial setup color. better constrast for the user. also fixed a bug where the initial theme color in the setup would get overriden by the setting's theme picker. so now, the setting's theme picker is lazily initialized * uses new color palette library * added a completed startup theme picker * added customizable spawn size and increased the rotation speed. also added a scale effect for nodes being focused * lowered focus speed * updated package * added theme picker image * Update README.md * updated paging theme image
- Loading branch information
Showing
16 changed files
with
330 additions
and
31 deletions.
There are no files selected for viewing
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
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
13 changes: 13 additions & 0 deletions
13
ElegantTimeline/Helpers/Extensions/AppTheme+PaletteColor.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,13 @@ | ||
// Kevin Li - 2:50 PM - 8/4/20 | ||
|
||
import ElegantColorPalette | ||
|
||
extension AppTheme { | ||
|
||
static let allPaletteColors = Self.allThemes.map { PaletteColor(name: $0.name, uiColor: $0.primaryuiColor) } | ||
|
||
static func theme(for paletteColor: PaletteColor) -> AppTheme { | ||
Self.allThemes.first(where: { $0.name == paletteColor.name })! | ||
} | ||
|
||
} |
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
18 changes: 18 additions & 0 deletions
18
ElegantTimeline/Helpers/Extensions/EnvironmentKey+IsSetup.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,18 @@ | ||
// Kevin Li - 6:39 PM - 8/4/20 | ||
|
||
import SwiftUI | ||
|
||
struct IsSetupKey: EnvironmentKey { | ||
|
||
static var defaultValue: Bool = true | ||
|
||
} | ||
|
||
extension EnvironmentValues { | ||
|
||
var isSetup: Bool { | ||
get { self[IsSetupKey.self] } | ||
set { self[IsSetupKey.self] = newValue } | ||
} | ||
|
||
} |
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
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
89 changes: 89 additions & 0 deletions
89
ElegantTimeline/Views/HomeView/StartupThemePickerOverlay/StartupThemePicker.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,89 @@ | ||
// Kevin Li - 12:20 PM - 8/5/20 | ||
|
||
import ElegantColorPalette | ||
import SpriteKit | ||
import SwiftUI | ||
|
||
struct StartupThemePicker: UIViewRepresentable { | ||
|
||
typealias UIViewType = ColorPaletteView | ||
|
||
@Binding var selectedColor: PaletteColor? | ||
let colors: [PaletteColor] | ||
let didSelectColor: (PaletteColor) -> Void | ||
|
||
let showExitAnimation: Bool | ||
let exitDuration: TimeInterval | ||
|
||
func makeUIView(context: Context) -> ColorPaletteView { | ||
ColorPaletteView(colors: colors, selectedColor: selectedColor) | ||
.didSelectColor(groupedCallback) | ||
.nodeStyle(NoNameNodeStyle()) | ||
.canMoveFocusedNode(false) | ||
.rotation(multiplier: 5) | ||
.spawnConfiguration(widthRatio: 1, heightRatio: 1) | ||
.focus(speed: 1000) | ||
} | ||
|
||
private func groupedCallback(_ color: PaletteColor) { | ||
bindingCallback(color) | ||
didSelectColor(color) | ||
} | ||
|
||
private func bindingCallback(_ color: PaletteColor) { | ||
DispatchQueue.main.async { | ||
withAnimation(.easeInOut(duration: 0.5)) { | ||
self.selectedColor = color | ||
} | ||
} | ||
} | ||
|
||
func updateUIView(_ uiView: ColorPaletteView, context: Context) { | ||
if showExitAnimation { | ||
beginExitAnimation(forScene: uiView.paletteScene) | ||
} | ||
} | ||
|
||
private func beginExitAnimation(forScene scene: ColorPaletteScene) { | ||
guard let selectedNode = scene.selectedColorNode else { return } | ||
|
||
scaleAndFadeNode(selectedNode) | ||
|
||
scene.allColorNodes | ||
.filter { $0 != selectedNode } | ||
.forEach { node in | ||
pushNodeOutOfBounds(node) | ||
} | ||
} | ||
|
||
private func scaleAndFadeNode(_ node: ColorNode) { | ||
node.physicsBody?.isDynamic = false | ||
|
||
let scaleAction = SKAction.scale(to: 5, duration: exitDuration) | ||
let fadeAction = SKAction.fadeOut(withDuration: exitDuration) | ||
let scaleFadeAction = SKAction.group([scaleAction, fadeAction]) | ||
node.run(scaleFadeAction) | ||
} | ||
|
||
private func pushNodeOutOfBounds(_ node: ColorNode) { | ||
// Basically makes the node not collide with anything -> pushes out of screen bounds | ||
node.physicsBody?.collisionBitMask = .zero | ||
|
||
let positionVector = CGVector(dx: node.position.x, dy: node.position.y) | ||
let pushVector = CGVector(dx: positionVector.dx*10, dy: positionVector.dy*10) | ||
node.physicsBody?.velocity = pushVector | ||
} | ||
|
||
} | ||
|
||
private struct NoNameNodeStyle: NodeStyle { | ||
|
||
func updateNode(configuration: Configuration) -> ColorNode { | ||
configuration.node | ||
.scaleFade(!configuration.isFirstShown, | ||
scale: configuration.isPressed ? 0.9 : (configuration.isFocusing ? 1.3 : 1), | ||
opacity: configuration.isPressed ? 0.3 : 1) | ||
.startUp(configuration.isFirstShown) | ||
} | ||
|
||
} |
Oops, something went wrong.