Plain timeline styler (#94)

* #92 Create `TimelineStyle` and store it in user defaults

* #92 Create `TimelineStyler` observable environment object

* #92 Use timeline list row insets from the styler

* #92 remove sender view, move header into the styler views

* #92 Add timeline style option in settings

* #92 Add changelog

* #92 refactor some code duplications

* #92 Fix `TimelineStyle`targets

* #92 Fix `TimelineStyle` targets

* #92 Fix PR remarks

* #92 Fix inline PR comments

* #92 Fix UI tests

* #92 Rename bubbled to bubbles
This commit is contained in:
ismailgulek
2022-06-27 13:27:09 +03:00
committed by GitHub
parent b6b8b4be26
commit 36c34503fc
21 changed files with 386 additions and 234 deletions
@@ -0,0 +1,44 @@
//
// TimelineStyle.swift
// ElementX
//
// Created by Ismail on 24.06.2022.
// Copyright © 2022 Element. All rights reserved.
//
import Foundation
import SwiftUI
enum TimelineStyle: String, CaseIterable {
case plain
case bubbles
/// List row insets for a timeline
var listRowInsets: EdgeInsets {
switch self {
case .plain:
return EdgeInsets(top: 4, leading: 20, bottom: 4, trailing: 20)
case .bubbles:
return EdgeInsets(top: 1, leading: 8, bottom: 1, trailing: 8)
}
}
}
// MARK: - Environment
private struct TimelineStyleKey: EnvironmentKey {
static let defaultValue = BuildSettings.defaultRoomTimelineStyle
}
extension EnvironmentValues {
var timelineStyle: TimelineStyle {
get { self[TimelineStyleKey.self] }
set { self[TimelineStyleKey.self] = newValue }
}
}
extension View {
func timelineStyle(_ style: TimelineStyle) -> some View {
environment(\.timelineStyle, style)
}
}