Skip to content

Commit

Permalink
Merge pull request #184 from makinosp/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
makinosp authored Nov 4, 2024
2 parents 5582a17 + 295642e commit 51fde2d
Show file tree
Hide file tree
Showing 28 changed files with 298 additions and 206 deletions.
4 changes: 2 additions & 2 deletions Harmonie.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.9.7;
MARKETING_VERSION = 0.9.8;
PRODUCT_BUNDLE_IDENTIFIER = jp.mknn.harmonie;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -510,7 +510,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.9.7;
MARKETING_VERSION = 0.9.8;
PRODUCT_BUNDLE_IDENTIFIER = jp.mknn.harmonie;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"location" : "https://github.com/makinosp/vrckit",
"state" : {
"branch" : "develop",
"revision" : "7c88c46ceaf6d12b048cd03220c844de07206ec2"
"revision" : "8a803ceb610901c5061b7fb9aa4f7e6bfecd56f4"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion harmonie/Components/GradientOverlayImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct GradientOverlayImageView<TopContent, BottomContent>: View where TopConten
@Init(.internal) private let imageUrl: URL?
@Init(.internal, default: nil) private let thumbnailImageUrl: URL?
@Init(.internal) private let height: CGFloat
@Init(.internal, default: WindowUtil.width) private let maxWidth: CGFloat
@Init(.internal) private let maxWidth: CGFloat
@Init(.internal, default: Gradient(colors: [.black.opacity(0.5), .clear])) private let gradient: Gradient
@Init(.internal, default: { EmptyView() }, escaping: true) private let topContent: () -> TopContent
@Init(.internal, default: { EmptyView() }, escaping: true) private let bottomContent: () -> BottomContent
Expand Down
14 changes: 14 additions & 0 deletions harmonie/Extensions/GeometryProxy+Equatable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// GeometryProxy+Equatable.swift
// Harmonie
//
// Created by makinosp on 2024/11/04.
//

import SwiftUICore

extension GeometryProxy: @retroactive Equatable {
public static func == (lhs: GeometryProxy, rhs: GeometryProxy) -> Bool {
lhs.size == rhs.size && lhs.safeAreaInsets == rhs.safeAreaInsets
}
}
2 changes: 1 addition & 1 deletion harmonie/Previews/AppViewModel+PreviewInitializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ extension AppViewModel {
convenience init(isPreviewMode: Bool) {
self.init()
services = APIServiceUtil(isPreviewMode: true, client: client)
user = PreviewDataProvider.shared.previewUser
user = PreviewData.shared.previewUser
}
}
49 changes: 40 additions & 9 deletions harmonie/Previews/Models/Friend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation
import VRCKit

extension PreviewDataProvider {
extension PreviewData {
struct FriendSet {
let friend: Friend
let userDetail: UserDetail
Expand All @@ -27,20 +27,51 @@ extension PreviewDataProvider {
}
}

extension PreviewDataProvider.FriendSet {
extension PreviewData.FriendSet {
/// Initialize from world information
init(
id: UUID,
id: UUID = UUID(),
profile: PreviewData.Profile? = PreviewData.Profile.random,
world: World,
status: UserStatus
) {
let location: Location = .id(PreviewData.instanceId(world))
self.init(
friend: Friend(
id: id,
profile: profile,
location: location,
status: status
),
userDetail: PreviewData.userDetail(
id: id,
profile: profile,
location: location,
state: status == .offline ? .offline : .active,
status: status
)
)
}
}

extension PreviewData.FriendSet {
/// Initialize from world information
init(
id: UUID = UUID(),
profile: PreviewData.Profile? = PreviewData.Profile.random,
location: Location,
status: UserStatus
) {
self.init(
friend: Friend(
id: id,
profile: profile,
location: location,
status: status
),
userDetail: PreviewDataProvider.userDetail(
userDetail: PreviewData.userDetail(
id: id,
profile: profile,
location: location,
state: status == .offline ? .offline : .active,
status: status
Expand All @@ -52,17 +83,17 @@ extension PreviewDataProvider.FriendSet {
private extension Friend {
init(
id: UUID,
avatarImageUrl: URL? = PreviewDataProvider.iconImageUrl,
displayName: String = PreviewString.Name.randomValue,
profile: PreviewData.Profile? = PreviewData.Profile.random,
avatarImageUrl: URL? = PreviewData.iconImageUrl,
location: Location,
status: UserStatus
) {
self.init(
bio: "Biography",
bioLinks: SafeDecodingArray(),
avatarImageUrl: avatarImageUrl,
avatarThumbnailUrl: avatarImageUrl,
displayName: displayName,
avatarImageUrl: profile?.imageUrl(),
avatarThumbnailUrl: profile?.imageUrl(),
displayName: profile?.name ?? "",
id: "usr_\(id.uuidString)",
isFriend: true,
lastLogin: Date(),
Expand Down
2 changes: 1 addition & 1 deletion harmonie/Previews/Models/FriendsLocation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import VRCKit

extension PreviewDataProvider {
extension PreviewData {
static var friendsLocation: FriendsLocation {
FriendsLocation(
location: .offline,
Expand Down
25 changes: 17 additions & 8 deletions harmonie/Previews/Models/Instance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,33 @@
import Foundation
import VRCKit

extension PreviewDataProvider {
extension PreviewData {
static func instance(worldId: UUID, instanceId: Int) -> Instance {
Instance(world: bar)
}

static func instance() -> Instance {
static var instance: Instance {
Instance(world: bar)
}

static let instance1 = Instance(world: bar)
static let instance2 = Instance(world: casino)
static func instanceId(_ world: World) -> Instance.ID {
"\(world.id):0"
}

static let instanceMap: [Instance.ID: Instance] = [
instanceId(bar): Instance(world: bar, userCount: 25),
instanceId(casino): Instance(world: casino, userCount: 25),
instanceId(fuji): Instance(world: fuji, userCount: 25),
instanceId(chinatown): Instance(world: chinatown, userCount: 25),
instanceId(nightCity): Instance(world: nightCity, userCount: 25),
]
}

private extension Instance {
init(world: World, instanceId: Int = 0) {
init(world: World, instanceId: Int = 0, capacity: Int = 32, userCount: Int = 0) {
self.init(
active: true,
capacity: 32,
capacity: capacity,
full: false,
groupAccessType: nil,
id: "\(world.id):\(instanceId)",
Expand All @@ -35,11 +44,11 @@ private extension Instance {
ownerId: "usr_\(UUID().uuidString)",
permanent: false,
platforms: Platforms(),
recommendedCapacity: 32,
recommendedCapacity: capacity,
region: Region.allCases.randomElement() ?? .us,
tags: [],
type: [.public, .friends].randomElement() ?? .public,
userCount: 0,
userCount: userCount,
world: world
)
}
Expand Down
21 changes: 0 additions & 21 deletions harmonie/Previews/Models/PreviewString.swift

This file was deleted.

59 changes: 59 additions & 0 deletions harmonie/Previews/Models/Profile.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// PreviewProfile.swift
// Harmonie
//
// Created by makinosp on 2024/10/20.
//

import Foundation
import VRCKit

extension PreviewData {
enum Profile: String, CaseIterable {
case emma
case josh
case clarke
case nathalie
case meihua
case stella
}
}

extension PreviewData.Profile {
var name: String {
rawValue.capitalized
}

static var random: Self? {
allCases.randomElement()
}

static var randomName: String {
random?.rawValue.capitalized ?? ""
}

static var randomImageUrl: URL? {
random?.imageUrl()
}
}

extension PreviewData.Profile: ImageUrlRepresentable {
func imageUrl(_ resolution: ImageResolution = .origin) -> URL? {
let path: String
switch self {
case .emma:
path = "/00/64/j71jho9d_o.jpeg"
case .josh:
path = "/4c/65/8mxWMTxR_o.jpg"
case .clarke:
path = "/27/09/ooNrEkFY_o.jpg"
case .nathalie:
path = "/46/2a/PjWXRlvt_o.jpg"
case .meihua:
path = "/55/ca/a2MRVLCx_o.jpg"
case .stella:
path = "/2f/73/4L6Bn9x9_o.jpg"
}
return URL(string: PreviewData.imageBaseURL + path)
}
}
34 changes: 18 additions & 16 deletions harmonie/Previews/Models/UserDetail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,35 @@
import Foundation
import VRCKit

extension PreviewDataProvider {
static func previewUserDetail(id: UUID, instance: Instance) -> UserDetail {
UserDetail(
id: id,
location: .id(instance.id),
state: .active,
status: .active,
isFriend: false
)
extension PreviewData {
static func userDetail(id: UUID, instance: Instance) -> UserDetail {
UserDetail(id: id, location: .id(instance.id), state: .active, status: .active, isFriend: false)
}

static func userDetail(
id: UUID,
profile: Profile? = nil,
location: Location,
state: User.State,
status: UserStatus,
isFriend: Bool = true
) -> UserDetail {
UserDetail(id: id, location: location, state: state, status: status, isFriend: isFriend)
UserDetail(
id: id,
profile: profile,
location: location,
state: state,
status: status,
isFriend: isFriend
)
}
}

private extension UserDetail {
init(
id: UUID = UUID(),
profile: PreviewData.Profile? = PreviewData.Profile.random,
bio: String = "Demo",
displayName: String = PreviewString.Name.randomValue,
location: Location,
state: User.State,
status: UserStatus,
Expand All @@ -46,19 +48,19 @@ private extension UserDetail {
self.init(
bio: bio,
bioLinks: SafeDecodingArray(),
avatarImageUrl: PreviewDataProvider.iconImageUrl,
avatarThumbnailUrl: PreviewDataProvider.iconImageUrl,
displayName: displayName,
avatarImageUrl: profile?.imageUrl(),
avatarThumbnailUrl: profile?.imageUrl(),
displayName: profile?.name ?? "",
id: "usr_\(id.uuidString)",
isFriend: isFriend,
lastLogin: Date(),
lastPlatform: "standalonewindows",
profilePicOverride: PreviewDataProvider.iconImageUrl,
profilePicOverride: profile?.imageUrl(),
state: state,
status: status,
statusDescription: statusDescription,
tags: UserTags(),
userIcon: PreviewDataProvider.iconImageUrl,
userIcon: profile?.imageUrl(),
location: location,
friendKey: "",
dateJoined: dateJoined,
Expand Down
Loading

0 comments on commit 51fde2d

Please sign in to comment.