-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Boscojwho/improve comment show hide animations (#426)
Co-authored-by: Eric Andrews <[email protected]>
- Loading branch information
1 parent
5204022
commit c561efa
Showing
6 changed files
with
111 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Comments.swift | ||
// Mlem | ||
// | ||
// Created by Bosco Ho on 2023-08-03. | ||
// | ||
|
||
import SwiftUI | ||
|
||
internal extension Animation { | ||
|
||
/// Animation for expanding or collapsing a comment and its child comments. | ||
static func showHideComment(_ collapse: Bool) -> Animation { | ||
let standard = (0.4, 1.0, collapse ? 0.25 : 0.3) | ||
let animationValues = standard | ||
return .interactiveSpring( | ||
response: animationValues.0, | ||
dampingFraction: animationValues.1, | ||
blendDuration: animationValues.2) | ||
} | ||
} | ||
|
||
internal extension AnyTransition { | ||
|
||
static func markdownView() -> AnyTransition { | ||
.opacity | ||
} | ||
|
||
static func commentView() -> AnyTransition { | ||
.move(edge: .top).combined(with: .opacity) | ||
} | ||
} |
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,20 @@ | ||
// | ||
// Double.swift | ||
// Mlem | ||
// | ||
// Created by Bosco Ho on 2023-08-07. | ||
// | ||
|
||
import Foundation | ||
|
||
// MARK: - SwiftUI | ||
extension Double { | ||
|
||
/// Use this value in SwiftUI to modify a view to be the top-most layer. | ||
/// | ||
/// This sentinel value exists because using `Int.max` doesn't work. | ||
static var maxZIndex: Double { | ||
/// [2023.08] `Int.max` doesn't work, which is why this is set to just some big value. | ||
return 99999 | ||
} | ||
} |
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
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