Skip to content

Commit

Permalink
Merge pull request #123 from makinosp/develop
Browse files Browse the repository at this point in the history
update: bump up to 0.7.0
  • Loading branch information
makinosp authored Sep 20, 2024
2 parents c6ef77c + 932d05f commit 7412271
Show file tree
Hide file tree
Showing 14 changed files with 255 additions and 107 deletions.
4 changes: 2 additions & 2 deletions Harmonie.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.6.0;
MARKETING_VERSION = 0.7.0;
PRODUCT_BUNDLE_IDENTIFIER = jp.mknn.harmonie;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -505,7 +505,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.6.0;
MARKETING_VERSION = 0.7.0;
PRODUCT_BUNDLE_IDENTIFIER = jp.mknn.harmonie;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
42 changes: 42 additions & 0 deletions harmonie/Components/BittenCircleMask.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// BittenCircleMask.swift
// Harmonie
//
// Created by xili on 2024/09/18.
//

import SwiftUI

struct BittenCircleMask: Shape {
private let biteSize: CGSize
private let offsetRatio: CGFloat

init(biteSize: CGSize, offsetRatio: CGFloat = 0.65) {
self.biteSize = biteSize
self.offsetRatio = offsetRatio
}

func path(in rect: CGRect) -> Path {
var path = rectanglePath(rect)
path.addPath(circlePath(rect))
return path
}

private func rectanglePath(_ rect: CGRect) -> Path {
Rectangle().path(in: rect)
}

private func circlePath(_ rect: CGRect) -> Path {
Circle()
.path(in: circleRect(rect, size: biteSize))
}

private func circleRect(_ rect: CGRect, size: CGSize) -> CGRect {
CGRect(origin: .zero, size: size)
.offsetBy(dx: offsetBy(rect.maxX), dy: offsetBy(rect.maxX))
}

private func offsetBy(_ maxX: CGFloat) -> CGFloat {
maxX * offsetRatio
}
}
47 changes: 47 additions & 0 deletions harmonie/Components/BittenView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// BittenView.swift
// Harmonie
//
// Created by xili on 2024/09/18.
//

import SwiftUI

struct BittenView<Content>: View where Content: View {
@State private var size: CGSize?
private let content: Content
private let ratio: CGFloat

init(ratio: CGFloat = 0.4, @ViewBuilder content: () -> Content) {
self.content = content()
self.ratio = ratio
}

private var transformed: CGSize {
guard let size = size else { return .zero }
return CGSize(width: size.width * ratio, height: size.height * ratio)
}

var body: some View {
content
.mask(
BittenCircleMask(biteSize: transformed)
.fill(style: FillStyle(eoFill: true))
)
.background {
GeometryReader { geometry in
Color.clear.onAppear {
size = geometry.size
}
}
}
}
}

#Preview {
BittenView {
Circle()
.fill(.blue)
.frame(width: 120, height: 120)
}
}
4 changes: 3 additions & 1 deletion harmonie/Components/SectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import SwiftUI

struct SectionView<Content>: View where Content: View {
var content: Content
private let content: Content

init(@ViewBuilder content: () -> Content) {
self.content = content()
}

var body: some View {
VStack(alignment: .leading) {
content
Expand Down
52 changes: 52 additions & 0 deletions harmonie/Components/StatusIndicator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// StatusIndicator.swift
// Harmonie
//
// Created by xili on 2024/09/19.
//

import SwiftUI

struct StatusIndicator<S>: View where S: ShapeStyle {
private let content: S
private let isCutOut: Bool
private let outerSize: CGSize

init(_ content: S, outerSize: CGSize, isCutOut: Bool = false) {
self.content = content
self.outerSize = outerSize
self.isCutOut = isCutOut
}

private var frameSize: CGSize {
outerSize * 0.3
}

private var cutoutSize: CGSize {
outerSize * 0.15
}

private var offset: CGSize {
outerSize * 0.36
}

var body: some View {
Circle()
.fill(content)
.frame(size: frameSize)
.overlay {
Circle()
.blendMode(.destinationOut)
.frame(size: isCutOut ? cutoutSize : .zero)
}
.compositingGroup()
.offset(x: offset.width, y: offset.height)
}
}

#Preview {
StatusIndicator(
.blue,
outerSize: CGSize(width: 120, height: 120)
)
}
32 changes: 32 additions & 0 deletions harmonie/Components/UserIcon.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// UserIcon.swift
// Harmonie
//
// Created by makinosp on 2024/09/20.
//

import SwiftUI
import VRCKit

struct UserIcon: View {
private let user: any ProfileElementRepresentable
private let size: CGSize

init(user: any ProfileElementRepresentable, size: CGSize) {
self.user = user
self.size = size
}

var body: some View {
BittenView {
CircleURLImage(imageUrl: user.imageUrl(.x256), size: size)
}
.overlay {
StatusIndicator(
user.status.color,
outerSize: size,
isCutOut: user.platform == .web
)
}
}
}
14 changes: 14 additions & 0 deletions harmonie/Extensions/CGSize+Operator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// CGSize+Operator.swift
// Harmonie
//
// Created by makinosp on 2024/09/20.
//

import CoreGraphics

extension CGSize {
static func * (lhs: CGSize, rhs: CGFloat) -> CGSize {
CGSize(width: lhs.width * rhs, height: lhs.height * rhs)
}
}
10 changes: 1 addition & 9 deletions harmonie/Views/Favorite/FavoriteFriendListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,7 @@ struct FavoriteFriendListView: View {
Label {
Text(friend.displayName)
} icon: {
ZStack {
Circle()
.foregroundStyle(friend.status.color)
.frame(size: Constants.IconSize.thumbnailOutside)
CircleURLImage(
imageUrl: friend.imageUrl(.x256),
size: Constants.IconSize.thumbnail
)
}
UserIcon(user: friend, size: Constants.IconSize.thumbnail)
}
}
.frame(maxWidth: .infinity, alignment: .leading)
Expand Down
10 changes: 1 addition & 9 deletions harmonie/Views/Friend/FriendsListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,7 @@ struct FriendsListView: View, FriendServicePresentable {
Text(friend.displayName)
}
} icon: {
ZStack {
Circle()
.foregroundStyle(friend.status.color)
.frame(size: Constants.IconSize.thumbnailOutside)
CircleURLImage(
imageUrl: friend.imageUrl(.x256),
size: Constants.IconSize.thumbnail
)
}
UserIcon(user: friend, size: Constants.IconSize.thumbnail)
}
}
.overlay { overlayView }
Expand Down
17 changes: 4 additions & 13 deletions harmonie/Views/Location/LocationCardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ struct LocationCardView: View, InstanceServicePresentable {
ScrollView(.horizontal) {
HStack(spacing: -8) {
ForEach(location.friends) { friend in
friendThumbnail(friend: friend)
CircleURLImage(
imageUrl: friend.imageUrl(.x256),
size: Constants.IconSize.thumbnail
)
}
}
}
Expand All @@ -72,16 +75,4 @@ struct LocationCardView: View, InstanceServicePresentable {
.map { $0.description }
.joined(separator: " / ")
}

private func friendThumbnail(friend: Friend) -> some View {
ZStack {
Circle()
.foregroundStyle(friend.status.color)
.frame(size: Constants.IconSize.thumbnailOutside)
CircleURLImage(
imageUrl: friend.imageUrl(.x256),
size: Constants.IconSize.thumbnail
)
}
}
}
10 changes: 1 addition & 9 deletions harmonie/Views/Location/LocationDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,7 @@ struct LocationDetailView: View {
Label {
Text(friend.displayName)
} icon: {
ZStack {
Circle()
.foregroundStyle(friend.status.color)
.frame(size: Constants.IconSize.thumbnailOutside)
CircleURLImage(
imageUrl: friend.imageUrl(.x256),
size: Constants.IconSize.thumbnail
)
}
UserIcon(user: friend, size: Constants.IconSize.thumbnail)
}
.frame(maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle())
Expand Down
32 changes: 13 additions & 19 deletions harmonie/Views/Setting/Profile/SettingsView+ProfileSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,25 @@ import VRCKit

extension SettingsView {
func profileSection(user: User) -> some View {
Section(header: Text("My Profile")) {
Button {
destination = .userDetail
} label: {
HStack(alignment: .center) {
Label {
Text(user.displayName)
} icon: {
CircleURLImage(
imageUrl: user.imageUrl(.x256),
size: Constants.IconSize.ll
)
}
Spacer()
Section(header: Text("Profile")) {
LabeledContent {
if UIDevice.current.userInterfaceIdiom == .phone {
Constants.Icon.forward
}
.frame(maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle())
} label: {
Label {
Text(user.displayName)
} icon: {
UserIcon(user: user, size: Constants.IconSize.ll)
}
.padding(.vertical, 8)
}
.tag(Destination.userDetail)

Button {
isPresentedForm = true
} label: {
HStack(alignment: .center) {
Label("Edit", systemImage: "pencil")
}
Label("Edit", systemImage: "pencil")
}
}
.textCase(nil)
Expand Down
Loading

0 comments on commit 7412271

Please sign in to comment.