mirror of
https://github.com/metabolist/metatext.git
synced 2024-06-02 13:40:13 +00:00
Merge pull request #2 from iamdaniele/edge-to-edge
Add edge-to-edge view
This commit is contained in:
commit
9c0506e9e7
|
@ -207,6 +207,7 @@
|
||||||
"preferences.app.color-scheme.system" = "System";
|
"preferences.app.color-scheme.system" = "System";
|
||||||
"preferences.blocked-domains" = "Blocked Domains";
|
"preferences.blocked-domains" = "Blocked Domains";
|
||||||
"preferences.blocked-users" = "Blocked Users";
|
"preferences.blocked-users" = "Blocked Users";
|
||||||
|
"preferences.edge-to-edge-view" = "Edge to edge view";
|
||||||
"preferences.media" = "Media";
|
"preferences.media" = "Media";
|
||||||
"preferences.media.avatars" = "Avatars";
|
"preferences.media.avatars" = "Avatars";
|
||||||
"preferences.media.avatars.animate" = "Animate avatars";
|
"preferences.media.avatars.animate" = "Animate avatars";
|
||||||
|
@ -235,6 +236,7 @@
|
||||||
"preferences.notification-types" = "Notification Types";
|
"preferences.notification-types" = "Notification Types";
|
||||||
"preferences.notification-types.follow" = "Follow";
|
"preferences.notification-types.follow" = "Follow";
|
||||||
"preferences.notification-types.favourite" = "Favorite";
|
"preferences.notification-types.favourite" = "Favorite";
|
||||||
|
"preferences.notification-types.like" = "Like";
|
||||||
"preferences.notification-types.follow-request" = "Follow Request";
|
"preferences.notification-types.follow-request" = "Follow Request";
|
||||||
"preferences.notification-types.reblog" = "Reblog";
|
"preferences.notification-types.reblog" = "Reblog";
|
||||||
"preferences.notification-types.mention" = "Mention";
|
"preferences.notification-types.mention" = "Mention";
|
||||||
|
|
|
@ -190,6 +190,11 @@ public extension AppPreferences {
|
||||||
get { self[.showReblogAndFavoriteCounts] ?? false }
|
get { self[.showReblogAndFavoriteCounts] ?? false }
|
||||||
set { self[.showReblogAndFavoriteCounts] = newValue }
|
set { self[.showReblogAndFavoriteCounts] = newValue }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var edgeToEdgeView: Bool {
|
||||||
|
get { self[.edgeToEdgeView] ?? false }
|
||||||
|
set { self[.edgeToEdgeView] = newValue }
|
||||||
|
}
|
||||||
|
|
||||||
var requireDoubleTapToReblog: Bool {
|
var requireDoubleTapToReblog: Bool {
|
||||||
get { self[.requireDoubleTapToReblog] ?? false }
|
get { self[.requireDoubleTapToReblog] ?? false }
|
||||||
|
@ -243,6 +248,7 @@ private extension AppPreferences {
|
||||||
case notificationSounds
|
case notificationSounds
|
||||||
case openLinksInDefaultBrowser
|
case openLinksInDefaultBrowser
|
||||||
case useUniversalLinks
|
case useUniversalLinks
|
||||||
|
case edgeToEdgeView
|
||||||
}
|
}
|
||||||
|
|
||||||
subscript<T>(index: Item) -> T? {
|
subscript<T>(index: Item) -> T? {
|
||||||
|
|
|
@ -101,6 +101,8 @@ struct PreferencesView: View {
|
||||||
Text(option.localizedStringKey).tag(option)
|
Text(option.localizedStringKey).tag(option)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Toggle("preferences.edge-to-edge-view",
|
||||||
|
isOn: $identityContext.appPreferences.edgeToEdgeView)
|
||||||
Picker("preferences.display-favorites-as",
|
Picker("preferences.display-favorites-as",
|
||||||
selection: $identityContext.appPreferences.displayFavoritesAs) {
|
selection: $identityContext.appPreferences.displayFavoritesAs) {
|
||||||
ForEach(AppPreferences.DisplayFavoritesAs.allCases) { option in
|
ForEach(AppPreferences.DisplayFavoritesAs.allCases) { option in
|
||||||
|
|
|
@ -15,6 +15,7 @@ final class AttachmentsView: UIView {
|
||||||
private let hideButton = UIButton()
|
private let hideButton = UIButton()
|
||||||
private var aspectRatioConstraint: NSLayoutConstraint?
|
private var aspectRatioConstraint: NSLayoutConstraint?
|
||||||
private var cancellables = Set<AnyCancellable>()
|
private var cancellables = Set<AnyCancellable>()
|
||||||
|
var identityContext: IdentityContext?
|
||||||
|
|
||||||
var viewModel: AttachmentsRenderingViewModel? {
|
var viewModel: AttachmentsRenderingViewModel? {
|
||||||
didSet {
|
didSet {
|
||||||
|
@ -104,7 +105,7 @@ final class AttachmentsView: UIView {
|
||||||
|
|
||||||
initialSetup()
|
initialSetup()
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(*, unavailable)
|
@available(*, unavailable)
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
@ -126,6 +127,11 @@ extension AttachmentsView {
|
||||||
|
|
||||||
return height
|
return height
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func displayEdgeToEdge(_ edgeToEdge: Bool) {
|
||||||
|
layer.cornerRadius = edgeToEdge ? 0 : .defaultCornerRadius
|
||||||
|
}
|
||||||
|
|
||||||
var shouldAutoplay: Bool {
|
var shouldAutoplay: Bool {
|
||||||
guard !isHidden, let viewModel = viewModel, viewModel.shouldShowAttachments else { return false }
|
guard !isHidden, let viewModel = viewModel, viewModel.shouldShowAttachments else { return false }
|
||||||
|
|
||||||
|
@ -148,10 +154,11 @@ extension AttachmentsView {
|
||||||
private extension AttachmentsView {
|
private extension AttachmentsView {
|
||||||
// swiftlint:disable:next function_body_length
|
// swiftlint:disable:next function_body_length
|
||||||
func initialSetup() {
|
func initialSetup() {
|
||||||
|
let isEdgeToEdge = identityContext?.appPreferences.edgeToEdgeView ?? false
|
||||||
backgroundColor = .clear
|
backgroundColor = .clear
|
||||||
layoutMargins = .zero
|
layoutMargins = .zero
|
||||||
clipsToBounds = true
|
clipsToBounds = true
|
||||||
layer.cornerRadius = .defaultCornerRadius
|
layer.cornerRadius = isEdgeToEdge ? 0 : .defaultCornerRadius
|
||||||
addSubview(containerStackView)
|
addSubview(containerStackView)
|
||||||
containerStackView.translatesAutoresizingMaskIntoConstraints = false
|
containerStackView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
containerStackView.distribution = .fillEqually
|
containerStackView.distribution = .fillEqually
|
||||||
|
|
|
@ -88,7 +88,7 @@ private extension CompositionView {
|
||||||
parentViewModel: parentViewModel,
|
parentViewModel: parentViewModel,
|
||||||
autocompleteQueryPublisher: viewModel.$contentWarningAutocompleteQuery.eraseToAnyPublisher())
|
autocompleteQueryPublisher: viewModel.$contentWarningAutocompleteQuery.eraseToAnyPublisher())
|
||||||
|
|
||||||
stackView.addArrangedSubview(spoilerTextField)
|
stackView.addSubview(spoilerTextField)
|
||||||
spoilerTextField.borderStyle = .roundedRect
|
spoilerTextField.borderStyle = .roundedRect
|
||||||
spoilerTextField.adjustsFontForContentSizeCategory = true
|
spoilerTextField.adjustsFontForContentSizeCategory = true
|
||||||
spoilerTextField.font = .preferredFont(forTextStyle: .body)
|
spoilerTextField.font = .preferredFont(forTextStyle: .body)
|
||||||
|
@ -106,7 +106,7 @@ private extension CompositionView {
|
||||||
parentViewModel: parentViewModel,
|
parentViewModel: parentViewModel,
|
||||||
autocompleteQueryPublisher: viewModel.$autocompleteQuery.eraseToAnyPublisher())
|
autocompleteQueryPublisher: viewModel.$autocompleteQuery.eraseToAnyPublisher())
|
||||||
|
|
||||||
stackView.addArrangedSubview(textView)
|
addSubview(textView)
|
||||||
textView.keyboardType = .twitter
|
textView.keyboardType = .twitter
|
||||||
textView.isScrollEnabled = false
|
textView.isScrollEnabled = false
|
||||||
textView.adjustsFontForContentSizeCategory = true
|
textView.adjustsFontForContentSizeCategory = true
|
||||||
|
@ -125,6 +125,7 @@ private extension CompositionView {
|
||||||
textViewPlaceholder.textColor = .secondaryLabel
|
textViewPlaceholder.textColor = .secondaryLabel
|
||||||
textViewPlaceholder.text = NSLocalizedString("compose.prompt", comment: "")
|
textViewPlaceholder.text = NSLocalizedString("compose.prompt", comment: "")
|
||||||
|
|
||||||
|
attachmentsView.displayEdgeToEdge(parentViewModel.identityContext.appPreferences.edgeToEdgeView)
|
||||||
stackView.addArrangedSubview(attachmentsView)
|
stackView.addArrangedSubview(attachmentsView)
|
||||||
attachmentsView.isHidden_stackViewSafe = true
|
attachmentsView.isHidden_stackViewSafe = true
|
||||||
stackView.addArrangedSubview(attachmentUploadsStackView)
|
stackView.addArrangedSubview(attachmentUploadsStackView)
|
||||||
|
@ -282,8 +283,8 @@ private extension CompositionView {
|
||||||
changeIdentityButton.bottomAnchor.constraint(equalTo: avatarImageView.bottomAnchor),
|
changeIdentityButton.bottomAnchor.constraint(equalTo: avatarImageView.bottomAnchor),
|
||||||
changeIdentityButton.trailingAnchor.constraint(equalTo: avatarImageView.trailingAnchor),
|
changeIdentityButton.trailingAnchor.constraint(equalTo: avatarImageView.trailingAnchor),
|
||||||
stackView.leadingAnchor.constraint(equalTo: avatarImageView.trailingAnchor, constant: .defaultSpacing),
|
stackView.leadingAnchor.constraint(equalTo: avatarImageView.trailingAnchor, constant: .defaultSpacing),
|
||||||
stackView.topAnchor.constraint(greaterThanOrEqualTo: guide.topAnchor),
|
// stackView.topAnchor.constraint(greaterThanOrEqualTo: guide.topAnchor),
|
||||||
stackView.bottomAnchor.constraint(lessThanOrEqualTo: guide.bottomAnchor),
|
// stackView.bottomAnchor.constraint(lessThanOrEqualTo: guide.bottomAnchor),
|
||||||
textViewPlaceholder.leadingAnchor.constraint(equalTo: textView.leadingAnchor),
|
textViewPlaceholder.leadingAnchor.constraint(equalTo: textView.leadingAnchor),
|
||||||
textViewPlaceholder.topAnchor.constraint(equalTo: textView.topAnchor),
|
textViewPlaceholder.topAnchor.constraint(equalTo: textView.topAnchor),
|
||||||
textViewPlaceholder.trailingAnchor.constraint(equalTo: textView.trailingAnchor),
|
textViewPlaceholder.trailingAnchor.constraint(equalTo: textView.trailingAnchor),
|
||||||
|
|
|
@ -18,6 +18,7 @@ final class StatusView: UIView {
|
||||||
let accountLabel = UILabel()
|
let accountLabel = UILabel()
|
||||||
let nameButton = UIButton()
|
let nameButton = UIButton()
|
||||||
let timeLabel = UILabel()
|
let timeLabel = UILabel()
|
||||||
|
let timeSeparatorLabel = UILabel()
|
||||||
let bodyView = StatusBodyView()
|
let bodyView = StatusBodyView()
|
||||||
let showThreadIndicator = UIButton(type: .system)
|
let showThreadIndicator = UIButton(type: .system)
|
||||||
let contextParentTimeLabel = UILabel()
|
let contextParentTimeLabel = UILabel()
|
||||||
|
@ -39,6 +40,7 @@ final class StatusView: UIView {
|
||||||
private let avatarContainerView = UIView()
|
private let avatarContainerView = UIView()
|
||||||
private let nameAccountContainerStackView = UIStackView()
|
private let nameAccountContainerStackView = UIStackView()
|
||||||
private let nameAccountTimeStackView = UIStackView()
|
private let nameAccountTimeStackView = UIStackView()
|
||||||
|
private let nameTimeStackView = UIStackView()
|
||||||
private let contextParentTimeApplicationStackView = UIStackView()
|
private let contextParentTimeApplicationStackView = UIStackView()
|
||||||
private let timeVisibilityDividerLabel = UILabel()
|
private let timeVisibilityDividerLabel = UILabel()
|
||||||
private let visibilityApplicationDividerLabel = UILabel()
|
private let visibilityApplicationDividerLabel = UILabel()
|
||||||
|
@ -211,14 +213,21 @@ private extension StatusView {
|
||||||
displayNameLabel.setContentHuggingPriority(.required, for: .horizontal)
|
displayNameLabel.setContentHuggingPriority(.required, for: .horizontal)
|
||||||
displayNameLabel.setContentHuggingPriority(.required, for: .vertical)
|
displayNameLabel.setContentHuggingPriority(.required, for: .vertical)
|
||||||
displayNameLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
|
displayNameLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
|
||||||
nameAccountTimeStackView.addArrangedSubview(displayNameLabel)
|
// nameTimeStackView.addArrangedSubview(displayNameLabel)
|
||||||
|
|
||||||
accountLabel.font = .preferredFont(forTextStyle: .subheadline)
|
accountLabel.font = .preferredFont(forTextStyle: .subheadline)
|
||||||
accountLabel.adjustsFontForContentSizeCategory = true
|
accountLabel.adjustsFontForContentSizeCategory = true
|
||||||
accountLabel.textColor = .secondaryLabel
|
accountLabel.textColor = .secondaryLabel
|
||||||
accountLabel.setContentHuggingPriority(.required, for: .horizontal)
|
accountLabel.setContentHuggingPriority(.required, for: .horizontal)
|
||||||
accountLabel.setContentHuggingPriority(.required, for: .vertical)
|
accountLabel.setContentHuggingPriority(.required, for: .vertical)
|
||||||
nameAccountTimeStackView.addArrangedSubview(accountLabel)
|
|
||||||
|
timeSeparatorLabel.text = "∙ "
|
||||||
|
timeSeparatorLabel.font = .preferredFont(forTextStyle: .subheadline)
|
||||||
|
timeSeparatorLabel.adjustsFontForContentSizeCategory = true
|
||||||
|
timeSeparatorLabel.textColor = .secondaryLabel
|
||||||
|
timeSeparatorLabel.textAlignment = .right
|
||||||
|
timeSeparatorLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
|
||||||
|
timeSeparatorLabel.setContentHuggingPriority(.required, for: .vertical)
|
||||||
|
|
||||||
timeLabel.font = .preferredFont(forTextStyle: .subheadline)
|
timeLabel.font = .preferredFont(forTextStyle: .subheadline)
|
||||||
timeLabel.adjustsFontForContentSizeCategory = true
|
timeLabel.adjustsFontForContentSizeCategory = true
|
||||||
|
@ -226,10 +235,14 @@ private extension StatusView {
|
||||||
timeLabel.textAlignment = .right
|
timeLabel.textAlignment = .right
|
||||||
timeLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
|
timeLabel.setContentCompressionResistancePriority(.required, for: .horizontal)
|
||||||
timeLabel.setContentHuggingPriority(.required, for: .vertical)
|
timeLabel.setContentHuggingPriority(.required, for: .vertical)
|
||||||
nameAccountTimeStackView.addArrangedSubview(timeLabel)
|
nameTimeStackView.addArrangedSubview(displayNameLabel)
|
||||||
|
nameTimeStackView.addArrangedSubview(timeSeparatorLabel)
|
||||||
|
nameTimeStackView.addArrangedSubview(timeLabel)
|
||||||
|
|
||||||
|
nameAccountTimeStackView.addArrangedSubview(nameTimeStackView)
|
||||||
nameAccountContainerStackView.spacing = .defaultSpacing
|
nameAccountContainerStackView.spacing = .defaultSpacing
|
||||||
nameAccountContainerStackView.addArrangedSubview(nameAccountTimeStackView)
|
nameAccountContainerStackView.addArrangedSubview(nameAccountTimeStackView)
|
||||||
|
nameAccountTimeStackView.addArrangedSubview(accountLabel)
|
||||||
mainStackView.addArrangedSubview(nameAccountContainerStackView)
|
mainStackView.addArrangedSubview(nameAccountContainerStackView)
|
||||||
|
|
||||||
nameButton.translatesAutoresizingMaskIntoConstraints = false
|
nameButton.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
@ -484,7 +497,10 @@ private extension StatusView {
|
||||||
rebloggerAvatarImageView.isHidden = !viewModel.isReblog
|
rebloggerAvatarImageView.isHidden = !viewModel.isReblog
|
||||||
rebloggerAvatarImageView.sd_setImage(with: viewModel.isReblog ? viewModel.rebloggerAvatarURL : nil)
|
rebloggerAvatarImageView.sd_setImage(with: viewModel.isReblog ? viewModel.rebloggerAvatarURL : nil)
|
||||||
|
|
||||||
if isContextParent, avatarContainerView.superview !== nameAccountContainerStackView {
|
if viewModel.identityContext.appPreferences.edgeToEdgeView {
|
||||||
|
nameAccountContainerStackView.insertArrangedSubview(avatarContainerView, at: 0)
|
||||||
|
sideStackView.isHidden = true
|
||||||
|
} else if isContextParent, avatarContainerView.superview !== nameAccountContainerStackView {
|
||||||
nameAccountContainerStackView.insertArrangedSubview(avatarContainerView, at: 0)
|
nameAccountContainerStackView.insertArrangedSubview(avatarContainerView, at: 0)
|
||||||
} else if avatarContainerView.superview !== sideStackView {
|
} else if avatarContainerView.superview !== sideStackView {
|
||||||
sideStackView.insertArrangedSubview(avatarContainerView, at: 1)
|
sideStackView.insertArrangedSubview(avatarContainerView, at: 1)
|
||||||
|
@ -562,9 +578,9 @@ private extension StatusView {
|
||||||
nameButtonAccessibilityAttributedLabel.appendWithSeparator(viewModel.accountName)
|
nameButtonAccessibilityAttributedLabel.appendWithSeparator(viewModel.accountName)
|
||||||
nameButton.accessibilityAttributedLabel = nameButtonAccessibilityAttributedLabel
|
nameButton.accessibilityAttributedLabel = nameButtonAccessibilityAttributedLabel
|
||||||
|
|
||||||
nameAccountTimeStackView.axis = isContextParent ? .vertical : .horizontal
|
nameAccountTimeStackView.axis = .vertical
|
||||||
nameAccountTimeStackView.alignment = isContextParent ? .leading : .fill
|
nameAccountTimeStackView.alignment = .leading
|
||||||
nameAccountTimeStackView.spacing = isContextParent ? 0 : .compactSpacing
|
nameAccountTimeStackView.spacing = 0
|
||||||
|
|
||||||
contextParentTopNameAccountSpacingView.removeFromSuperview()
|
contextParentTopNameAccountSpacingView.removeFromSuperview()
|
||||||
contextParentBottomNameAccountSpacingView.removeFromSuperview()
|
contextParentBottomNameAccountSpacingView.removeFromSuperview()
|
||||||
|
@ -580,6 +596,8 @@ private extension StatusView {
|
||||||
timeLabel.accessibilityLabel = viewModel.accessibilityTime
|
timeLabel.accessibilityLabel = viewModel.accessibilityTime
|
||||||
timeLabel.isHidden = isContextParent
|
timeLabel.isHidden = isContextParent
|
||||||
|
|
||||||
|
timeSeparatorLabel.isHidden = isContextParent
|
||||||
|
|
||||||
bodyView.viewModel = viewModel
|
bodyView.viewModel = viewModel
|
||||||
|
|
||||||
showThreadIndicator.isHidden = !viewModel.configuration.isReplyOutOfContext
|
showThreadIndicator.isHidden = !viewModel.configuration.isReplyOutOfContext
|
||||||
|
|
|
@ -51,6 +51,7 @@ final class StatusBodyView: UIView {
|
||||||
|
|
||||||
contentTextView.isHidden = !viewModel.shouldShowContent
|
contentTextView.isHidden = !viewModel.shouldShowContent
|
||||||
|
|
||||||
|
attachmentsView.displayEdgeToEdge(viewModel.identityContext.appPreferences.edgeToEdgeView)
|
||||||
attachmentsView.isHidden = viewModel.attachmentViewModels.isEmpty
|
attachmentsView.isHidden = viewModel.attachmentViewModels.isEmpty
|
||||||
attachmentsView.viewModel = viewModel
|
attachmentsView.viewModel = viewModel
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ extension CGFloat {
|
||||||
static let defaultShadowRadius: Self = 2
|
static let defaultShadowRadius: Self = 2
|
||||||
static let systemMenuWidth: Self = 250
|
static let systemMenuWidth: Self = 250
|
||||||
static let systemMenuInset: Self = 15
|
static let systemMenuInset: Self = 15
|
||||||
|
static let tabBarEdgeInsetSize: Self = 64
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Float {
|
extension Float {
|
||||||
|
|
Loading…
Reference in a new issue