Avatars improvements

This commit is contained in:
Marcin Czachursk 2023-04-10 21:53:15 +02:00
parent 14b9785af2
commit d4dd16698d
7 changed files with 39 additions and 34 deletions

View File

@ -54,6 +54,7 @@ class ApplicationSettingsHandler {
applicationState.activeIcon = defaultSettings.activeIcon
applicationState.showSensitive = defaultSettings.showSensitive
applicationState.showPhotoDescription = defaultSettings.showPhotoDescription
applicationState.showAvatarsOnTimeline = defaultSettings.showAvatarsOnTimeline
if let menuPosition = MenuPosition(rawValue: Int(defaultSettings.menuPosition)) {
applicationState.menuPosition = menuPosition

View File

@ -17,6 +17,7 @@
F805DCF129DBEF83006A1FD9 /* ReportView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F805DCF029DBEF83006A1FD9 /* ReportView.swift */; };
F808641429756666009F035C /* NotificationRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F808641329756666009F035C /* NotificationRowView.swift */; };
F8121CA8298A86D600B466C7 /* InstanceRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8121CA7298A86D600B466C7 /* InstanceRowView.swift */; };
F815F60C29E49CF20044566B /* Avatar.swift in Sources */ = {isa = PBXBuildFile; fileRef = F815F60B29E49CF20044566B /* Avatar.swift */; };
F8210DCF2966B600001D9973 /* ImageRowAsync.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8210DCE2966B600001D9973 /* ImageRowAsync.swift */; };
F8210DD52966BB7E001D9973 /* Nuke in Frameworks */ = {isa = PBXBuildFile; productRef = F8210DD42966BB7E001D9973 /* Nuke */; };
F8210DD72966BB7E001D9973 /* NukeExtensions in Frameworks */ = {isa = PBXBuildFile; productRef = F8210DD62966BB7E001D9973 /* NukeExtensions */; };
@ -220,6 +221,7 @@
F805DCF029DBEF83006A1FD9 /* ReportView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportView.swift; sourceTree = "<group>"; };
F808641329756666009F035C /* NotificationRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationRowView.swift; sourceTree = "<group>"; };
F8121CA7298A86D600B466C7 /* InstanceRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstanceRowView.swift; sourceTree = "<group>"; };
F815F60B29E49CF20044566B /* Avatar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Avatar.swift; sourceTree = "<group>"; };
F8210DCE2966B600001D9973 /* ImageRowAsync.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageRowAsync.swift; sourceTree = "<group>"; };
F8210DDC2966CF17001D9973 /* StatusData+Status.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "StatusData+Status.swift"; sourceTree = "<group>"; };
F8210DDE2966CFC7001D9973 /* AttachmentData+Attachment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AttachmentData+Attachment.swift"; sourceTree = "<group>"; };
@ -784,6 +786,7 @@
F8F6E44F29BCE9030004795E /* Extensions */ = {
isa = PBXGroup;
children = (
F815F60B29E49CF20044566B /* Avatar.swift */,
F8F6E45029BCE9190004795E /* UIImage+Resize.swift */,
);
path = Extensions;
@ -983,6 +986,7 @@
F8F6E44C29BCC1F70004795E /* SmallWidgetView.swift in Sources */,
F864F76629BB91B400B13921 /* VernissageWidget.swift in Sources */,
F8F6E44D29BCC1F90004795E /* MediumWidgetView.swift in Sources */,
F815F60C29E49CF20044566B /* Avatar.swift in Sources */,
F8F6E44E29BCC1FB0004795E /* LargeWidgetView.swift in Sources */,
F864F76429BB91B400B13921 /* VernissageWidgetBundle.swift in Sources */,
F864F77D29BB9A4600B13921 /* AttachmentData+CoreDataClass.swift in Sources */,

View File

@ -19,7 +19,7 @@ public extension View {
private struct ImageAvatar: ViewModifier {
@EnvironmentObject var applicationState: ApplicationState
private let displayName: String?
private let avatarUrl: URL?
@ -49,7 +49,8 @@ private struct ImageAvatar: ViewModifier {
}
Text(displayName ?? "")
.foregroundColor(.white)
.font(.subheadline)
.foregroundColor(.white.opacity(0.8))
.fontWeight(.semibold)
.shadow(color: .black, radius: 2)
Spacer()

View File

@ -0,0 +1,24 @@
//
// https://mczachurski.dev
// Copyright © 2023 Marcin Czachurski and the repository contributors.
// Licensed under the Apache License 2.0.
//
import Foundation
import SwiftUI
extension Image {
func avatar(size: Double) -> some View {
self
.resizable()
.clipShape(Circle())
.aspectRatio(contentMode: .fit)
.frame(width: size, height: size)
.overlay(
Circle()
.stroke(Color.white.opacity(0.6), lineWidth: 1)
.frame(width: size, height: size)
)
.shadow(color: .black, radius: 2)
}
}

View File

@ -26,19 +26,11 @@ struct LargeWidgetView: View {
Spacer()
HStack {
uiAvatar
.resizable()
.clipShape(Circle())
.aspectRatio(contentMode: .fit)
.frame(width: 24, height: 24)
.overlay(
Circle()
.stroke(Color.white.opacity(0.6), lineWidth: 1)
.frame(width: 24, height: 24)
)
.shadow(color: .black, radius: 2)
.avatar(size: 24)
Text(entry.displayName ?? "")
.foregroundColor(.white)
.font(.subheadline)
.foregroundColor(.white.opacity(0.8))
.fontWeight(.semibold)
.shadow(color: .black, radius: 2)
Spacer()

View File

@ -26,19 +26,11 @@ struct MediumWidgetView: View {
Spacer()
HStack {
uiAvatar
.resizable()
.clipShape(Circle())
.aspectRatio(contentMode: .fit)
.frame(width: 24, height: 24)
.overlay(
Circle()
.stroke(Color.white.opacity(0.6), lineWidth: 1)
.frame(width: 24, height: 24)
)
.shadow(color: .black, radius: 2)
.avatar(size: 24)
Text(entry.displayName ?? "")
.foregroundColor(.white)
.font(.subheadline)
.foregroundColor(.white.opacity(0.8))
.fontWeight(.semibold)
.shadow(color: .black, radius: 2)
Spacer()

View File

@ -26,16 +26,7 @@ struct SmallWidgetView: View {
Spacer()
HStack {
uiAvatar
.resizable()
.clipShape(Circle())
.aspectRatio(contentMode: .fit)
.frame(width: 16, height: 16)
.overlay(
Circle()
.stroke(Color.white.opacity(0.6), lineWidth: 1)
.frame(width: 16, height: 16)
)
.shadow(color: .black, radius: 2)
.avatar(size: 16)
Spacer()
}