mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
pr suggestions
This commit is contained in:
@@ -521,11 +521,13 @@ extension TimelineTableViewController {
|
|||||||
/// Computes the formatted date text for the topmost visible timeline item
|
/// Computes the formatted date text for the topmost visible timeline item
|
||||||
/// and updates the floating date binding.
|
/// and updates the floating date binding.
|
||||||
func updateFloatingDate() {
|
func updateFloatingDate() {
|
||||||
guard let dateText = topmostVisibleDateText() else {
|
guard let dateText = newestVisibleDateText() else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Before updating it already schedule it's removal or the future
|
// Before updating it already schedule it's removal or the future.
|
||||||
|
// The schedule needs to happen regardless of a value change
|
||||||
|
// to extend the display duration of the floating date.
|
||||||
scheduleFloatingDateHide()
|
scheduleFloatingDateHide()
|
||||||
|
|
||||||
// Only update on changes to avoid needless SwiftUI recomputation.
|
// Only update on changes to avoid needless SwiftUI recomputation.
|
||||||
@@ -544,12 +546,12 @@ extension TimelineTableViewController {
|
|||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0, execute: workItem)
|
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0, execute: workItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the formatted date text for the topmost visible timeline item.
|
/// Returns the formatted date text for the newest visible timeline item.
|
||||||
///
|
///
|
||||||
/// The table view is flipped (unless VoiceOver is running), so the "topmost"
|
/// The table view is flipped (unless VoiceOver is running), so the "newest"
|
||||||
/// visible cell on screen is actually the *last* index path in `indexPathsForVisibleRows`
|
/// visible cell on screen is actually the *last* index path in `indexPathsForVisibleRows`
|
||||||
/// when the table is flipped, or the *first* when it is not.
|
/// when the table is flipped, or the *first* when it is not.
|
||||||
private func topmostVisibleDateText() -> String? {
|
private func newestVisibleDateText() -> String? {
|
||||||
guard let visibleIndexPaths = tableView.indexPathsForVisibleRows,
|
guard let visibleIndexPaths = tableView.indexPathsForVisibleRows,
|
||||||
!visibleIndexPaths.isEmpty else {
|
!visibleIndexPaths.isEmpty else {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ struct FloatingDateBadge: View {
|
|||||||
.foregroundColor(.compound.textPrimary)
|
.foregroundColor(.compound.textPrimary)
|
||||||
.padding(.horizontal, 16)
|
.padding(.horizontal, 16)
|
||||||
.padding(.vertical, 8)
|
.padding(.vertical, 8)
|
||||||
.background(Capsule()
|
.background(backgroundColor, in: .capsule)
|
||||||
.fill(backgroundColor))
|
|
||||||
.shadow(color: Color(red: 0.11, green: 0.11, blue: 0.13).opacity(0.1), radius: 12, x: 0, y: 4)
|
.shadow(color: Color(red: 0.11, green: 0.11, blue: 0.13).opacity(0.1), radius: 12, x: 0, y: 4)
|
||||||
.transition(.opacity)
|
.transition(.opacity)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user