Skip to content

Commit

Permalink
Merge pull request #134 from makinosp/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
makinosp authored Sep 23, 2024
2 parents 52c4700 + 8f72489 commit faecabf
Show file tree
Hide file tree
Showing 29 changed files with 126 additions and 124 deletions.
8 changes: 4 additions & 4 deletions Harmonie.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@
PRODUCT_BUNDLE_IDENTIFIER = jp.mknn.harmonie;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = minimal;
SWIFT_VERSION = 5.0;
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
Expand Down Expand Up @@ -510,8 +510,8 @@
PRODUCT_BUNDLE_IDENTIFIER = jp.mknn.harmonie;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = minimal;
SWIFT_VERSION = 5.0;
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"location" : "https://github.com/makinosp/vrckit",
"state" : {
"branch" : "develop",
"revision" : "8a41adc2b663853c33d9c2d7c2000d0f6b499ecb"
"revision" : "3e8473947c3044297be4647d8230381c16921090"
}
},
{
Expand Down
27 changes: 27 additions & 0 deletions harmonie/Components/NavigationLabel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// NavigationLabel.swift
// Harmonie
//
// Created by makinosp on 2024/09/22.
//

import SwiftUI

struct NavigationLabel<Label>: View where Label: View {
private let label: () -> Label

init(label: @escaping () -> Label) {
self.label = label
}

var body: some View {
LabeledContent(content: content, label: label)
}

@ViewBuilder
func content() -> some View {
if UIDevice.current.userInterfaceIdiom != .pad {
Constants.Icon.forward
}
}
}
13 changes: 11 additions & 2 deletions harmonie/Components/StatusIndicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,29 @@ import SwiftUI
struct StatusIndicator<S>: View where S: ShapeStyle {
private let content: S
private let isCutOut: Bool
private let size: CGSize?
private let outerSize: CGSize

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

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

private var frameSize: CGSize {
outerSize * 0.3
size ?? outerSize * 0.3
}

private var cutoutSize: CGSize {
outerSize * 0.15
frameSize * 0.5
}

private var offset: CGSize {
Expand Down
2 changes: 1 addition & 1 deletion harmonie/Protocols/AuthenticationServicePresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import VRCKit

@MainActor
protocol AuthenticationServicePresentable {
var appVM: AppViewModel { get }
}

extension AuthenticationServicePresentable {
@MainActor
var authenticationService: AuthenticationServiceProtocol {
appVM.isPreviewMode
? AuthenticationPreviewService(client: appVM.client)
Expand Down
2 changes: 1 addition & 1 deletion harmonie/Protocols/FavoriteServicePresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import VRCKit

@MainActor
protocol FavoriteServicePresentable {
var appVM: AppViewModel { get }
}

extension FavoriteServicePresentable {
@MainActor
var favoriteService: FavoriteServiceProtocol {
appVM.isPreviewMode
? FavoritePreviewService(client: appVM.client)
Expand Down
2 changes: 1 addition & 1 deletion harmonie/Protocols/FriendServicePresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import VRCKit

@MainActor
protocol FriendServicePresentable {
var appVM: AppViewModel { get }
}

extension FriendServicePresentable {
@MainActor
var friendService: FriendServiceProtocol {
appVM.isPreviewMode
? FriendPreviewService(client: appVM.client)
Expand Down
2 changes: 1 addition & 1 deletion harmonie/Protocols/InstanceServicePresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import VRCKit

@MainActor
protocol InstanceServicePresentable {
var appVM: AppViewModel { get }
}

extension InstanceServicePresentable {
@MainActor
var instanceService: InstanceServiceProtocol {
appVM.isPreviewMode
? InstancePreviewService(client: appVM.client)
Expand Down
2 changes: 1 addition & 1 deletion harmonie/Protocols/UserServicePresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import VRCKit

@MainActor
protocol UserServicePresentable {
var appVM: AppViewModel { get }
}

extension UserServicePresentable {
@MainActor
var userService: UserServiceProtocol {
appVM.isPreviewMode
? UserPreviewService(client: appVM.client)
Expand Down
2 changes: 1 addition & 1 deletion harmonie/Protocols/WorldServicePresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import VRCKit

@MainActor
protocol WorldServicePresentable {
var appVM: AppViewModel { get }
}

extension WorldServicePresentable {
@MainActor
var worldService: WorldServiceProtocol {
appVM.isPreviewMode
? WorldPreviewService(client: appVM.client)
Expand Down
1 change: 1 addition & 0 deletions harmonie/Utils/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ enum Constants {

enum IconSize {
static let thumbnail = CGSize(width: 32, height: 32)
static let indicator = CGSize(width: 20, height: 20)
static let ll = CGSize(width: 44, height: 44)
}

Expand Down
2 changes: 1 addition & 1 deletion harmonie/Utils/WindowUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import UIKit

enum WindowUtil {
@MainActor enum WindowUtil {
static var window: UIWindowScene? {
UIApplication.shared.connectedScenes.first as? UIWindowScene
}
Expand Down
8 changes: 4 additions & 4 deletions harmonie/ViewModels/AppViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class AppViewModel {
/// - Returns: Depending on the status, either `loggingIn` or `done` is returned.
func setup(service: AuthenticationServiceProtocol) async -> Step {
// check local data
guard !client.cookieManager.cookies.isEmpty else {
guard await !client.cookieManager.cookies.isEmpty else {
return .loggingIn
}
do {
Expand All @@ -51,23 +51,23 @@ final class AppViewModel {

private func setCredential(username: String, password: String, isSavedOnKeyChain: Bool) async {
isPreviewMode = isPreviewUser(username: username, password: password)
client.setCledentials(username: username, password: password)
await client.setCledentials(username: username, password: password)
if isSavedOnKeyChain {
_ = await KeychainUtil.shared.savePassword(password, for: username)
}
}

func login(username: String, password: String, isSavedOnKeyChain: Bool) async -> VerifyType? {
isPreviewMode = isPreviewUser(username: username, password: password)
client.setCledentials(username: username, password: password)
await client.setCledentials(username: username, password: password)
if isSavedOnKeyChain {
_ = await KeychainUtil.shared.savePassword(password, for: username)
}
return await login()
}

func login() async -> VerifyType? {
let service = isPreviewMode
let service: AuthenticationServiceProtocol = isPreviewMode
? AuthenticationPreviewService(client: client)
: AuthenticationService(client: client)
do {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// FriendViewModel+FilterUserStatus.swift
// FriendViewModel+FilterConditions.swift
// Harmonie
//
// Created by makinosp on 2024/09/16.
Expand All @@ -12,6 +12,16 @@ extension FriendViewModel {
case all, status(UserStatus)
var id: Int { hashValue }
}

enum FilterFavoriteGroups: Hashable, Identifiable {
case all, favoriteGroup(FavoriteGroup)
var id: Int { hashValue }
}

enum SortType: String, Hashable, Identifiable, CaseIterable {
case `default`, displayName, lastLogin, status
var id: Int { hashValue }
}
}

extension FriendViewModel.FilterUserStatus: CustomStringConvertible {
Expand All @@ -37,3 +47,13 @@ extension FriendViewModel.FilterUserStatus: CaseIterable {
]
}
}

extension FriendViewModel.SortType: CustomStringConvertible {
var description: String {
switch self {
case .displayName: "Name"
case .lastLogin: "Last Login"
default: rawValue.localizedCapitalized
}
}
}

This file was deleted.

2 changes: 1 addition & 1 deletion harmonie/ViewModels/Friend/FriendViewModel+Filters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import VRCKit

extension FriendViewModel {
func setFavoriteFriends(favoriteFriends: [FavoriteFriend]) {
func setFavoriteFriends(_ favoriteFriends: [FavoriteFriend]) {
self.favoriteFriends = favoriteFriends
}

Expand Down
23 changes: 0 additions & 23 deletions harmonie/ViewModels/Friend/FriendViewModel+SortType.swift

This file was deleted.

4 changes: 2 additions & 2 deletions harmonie/ViewModels/Friend/FriendViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final class FriendViewModel {
}

/// Fetch friends from API
func fetchAllFriends(service: FriendServiceProtocol) async throws {
func fetchAllFriends<T: FriendServiceProtocol>(service: T) async throws where T: Sendable {
async let onlineFriendsTask = service.fetchFriends(
count: user.onlineFriends.count + user.activeFriends.count,
offline: false
Expand All @@ -57,7 +57,7 @@ final class FriendViewModel {
)
onlineFriends = try await onlineFriendsTask
offlineFriends = try await offlineFriendsTask
friendsLocations = service.friendsGroupedByLocation(onlineFriends)
friendsLocations = await service.friendsGroupedByLocation(onlineFriends)
applyFilters()
}
}
24 changes: 8 additions & 16 deletions harmonie/Views/Favorite/FavoriteFriendListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ struct FavoriteFriendListView: View {
if let friends = favoriteVM.getFavoriteFriends(group.id) {
Section(header: Text(group.displayName)) {
ForEach(friends) { friend in
friendItem(friend)
.tag(Selected(id: friend.id))
NavigationLabel {
Label {
Text(friend.displayName)
} icon: {
UserIcon(user: friend, size: Constants.IconSize.thumbnail)
}
}
.tag(Selected(id: friend.id))
}
}
}
Expand All @@ -39,18 +45,4 @@ struct FavoriteFriendListView: View {
}
}
}

private func friendItem(_ friend: Friend) -> some View {
LabeledContent {
Constants.Icon.forward
} label: {
Label {
Text(friend.displayName)
} icon: {
UserIcon(user: friend, size: Constants.IconSize.thumbnail)
}
}
.frame(maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle())
}
}
6 changes: 1 addition & 5 deletions harmonie/Views/Friend/FriendsListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ struct FriendsListView: View, FriendServicePresentable {
var body: some View {
List(friendVM.filterResultFriends, selection: $selected) { friend in
Label {
LabeledContent {
if UIDevice.current.userInterfaceIdiom == .phone {
Constants.Icon.forward
}
} label: {
NavigationLabel {
Text(friend.displayName)
}
} icon: {
Expand Down
Loading

0 comments on commit faecabf

Please sign in to comment.