Skip to content

Commit

Permalink
Merge pull request #105 from makinosp/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
makinosp authored Sep 9, 2024
2 parents ecd43bb + 51da12a commit 59f5852
Show file tree
Hide file tree
Showing 20 changed files with 119 additions and 125 deletions.
5 changes: 3 additions & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
disabled_rules:
- identifier_name
- multiple_closures_with_trailing_closure
- non_optional_string_data_conversion

opt_in_rules:
- array_init
Expand All @@ -13,15 +14,15 @@ opt_in_rules:
- contains_over_filter_is_empty
- contains_over_first_not_nil
- contains_over_range_nil_comparison
# - convenience_type
- convenience_type
- empty_collection_literal
- empty_count
- extension_access_modifier
- fallthrough
- fatal_error_message
- first_where
- flatmap_over_map_reduce
# - force_unwrapping
- force_unwrapping
- identical_operands
- implicit_return
- implicitly_unwrapped_optional
Expand Down
25 changes: 6 additions & 19 deletions Harmonie.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
204709A52C7B47E100A56DF8 /* VRCKit in Frameworks */ = {isa = PBXBuildFile; productRef = 2096016C2C4BD30100D905AF /* VRCKit */; };
204709A62C7B47E100A56DF8 /* SwiftUIIntrospect in Frameworks */ = {isa = PBXBuildFile; productRef = 205D81A52C71B9D70047C1CC /* SwiftUIIntrospect */; };
20592B032C45640D00E1C8B8 /* AsyncSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = 20592B022C45640D00E1C8B8 /* AsyncSwiftUI */; };
20593CD92C8D4A8000D1305B /* Shimmer in Frameworks */ = {isa = PBXBuildFile; productRef = 20593CD82C8D4A8000D1305B /* Shimmer */; };
206AC9012BFA07AA00E0D5AE /* AsyncSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = 206AC9002BFA07AA00E0D5AE /* AsyncSwiftUI */; };
2094C4002C43BBC100F88986 /* VRCKit in Frameworks */ = {isa = PBXBuildFile; productRef = 2094C3FF2C43BBC100F88986 /* VRCKit */; };
20C7F8BB2C480E6800AC7A56 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 20C7F89E2C480E6800AC7A56 /* LICENSE */; };
20DC3C292C422786001101DB /* VRCKit in Frameworks */ = {isa = PBXBuildFile; productRef = 20DC3C282C422786001101DB /* VRCKit */; };
20E1D3722C8F467D00E00017 /* .swiftlint.yml in Resources */ = {isa = PBXBuildFile; fileRef = 20E1D3322C8F467D00E00017 /* .swiftlint.yml */; };
20F213DD2C11FB470061DE29 /* NukeUI in Frameworks */ = {isa = PBXBuildFile; productRef = 20F213DC2C11FB470061DE29 /* NukeUI */; };
/* End PBXBuildFile section */

Expand All @@ -46,6 +46,7 @@
20395DA32B945CD900003921 /* HarmonieTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HarmonieTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
20395DAD2B945CD900003921 /* HarmonieUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HarmonieUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
20C7F89E2C480E6800AC7A56 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
20E1D3322C8F467D00E00017 /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .swiftlint.yml; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
Expand Down Expand Up @@ -79,7 +80,6 @@
20395DC22B945EEF00003921 /* VRCKit in Frameworks */,
2014A0B32C3832690019C638 /* VRCKit in Frameworks */,
20DC3C292C422786001101DB /* VRCKit in Frameworks */,
20593CD92C8D4A8000D1305B /* Shimmer in Frameworks */,
206AC9012BFA07AA00E0D5AE /* AsyncSwiftUI in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -104,6 +104,7 @@
20395D882B945CD700003921 = {
isa = PBXGroup;
children = (
20E1D3322C8F467D00E00017 /* .swiftlint.yml */,
20C7F8982C480E6800AC7A56 /* Harmonie */,
20C7F89E2C480E6800AC7A56 /* LICENSE */,
20395D922B945CD700003921 /* Products */,
Expand Down Expand Up @@ -154,7 +155,6 @@
2052C7AD2C4BC97100B341D1 /* VRCKit */,
2096016C2C4BD30100D905AF /* VRCKit */,
205D81A52C71B9D70047C1CC /* SwiftUIIntrospect */,
20593CD82C8D4A8000D1305B /* Shimmer */,
);
productName = harmonie;
productReference = 20395D912B945CD700003921 /* Harmonie.app */;
Expand Down Expand Up @@ -239,7 +239,6 @@
20592B012C45640D00E1C8B8 /* XCRemoteSwiftPackageReference "async-swift-ui" */,
2096016B2C4BD30100D905AF /* XCRemoteSwiftPackageReference "vrckit" */,
205D81A42C71B9D70047C1CC /* XCRemoteSwiftPackageReference "swiftui-introspect" */,
20593CD72C8D4A8000D1305B /* XCRemoteSwiftPackageReference "SwiftUI-Shimmer" */,
);
productRefGroup = 20395D922B945CD700003921 /* Products */;
projectDirPath = "";
Expand All @@ -257,6 +256,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
20E1D3722C8F467D00E00017 /* .swiftlint.yml in Resources */,
20C7F8BB2C480E6800AC7A56 /* LICENSE in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -483,7 +483,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.5.0;
MARKETING_VERSION = 0.5.1;
PRODUCT_BUNDLE_IDENTIFIER = jp.mknn.harmonie;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -518,7 +518,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.5.0;
MARKETING_VERSION = 0.5.1;
PRODUCT_BUNDLE_IDENTIFIER = jp.mknn.harmonie;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -664,14 +664,6 @@
kind = branch;
};
};
20593CD72C8D4A8000D1305B /* XCRemoteSwiftPackageReference "SwiftUI-Shimmer" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/markiv/SwiftUI-Shimmer";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.5.1;
};
};
205D81A42C71B9D70047C1CC /* XCRemoteSwiftPackageReference "swiftui-introspect" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/siteline/swiftui-introspect";
Expand Down Expand Up @@ -725,11 +717,6 @@
package = 20592B012C45640D00E1C8B8 /* XCRemoteSwiftPackageReference "async-swift-ui" */;
productName = AsyncSwiftUI;
};
20593CD82C8D4A8000D1305B /* Shimmer */ = {
isa = XCSwiftPackageProductDependency;
package = 20593CD72C8D4A8000D1305B /* XCRemoteSwiftPackageReference "SwiftUI-Shimmer" */;
productName = Shimmer;
};
205D81A52C71B9D70047C1CC /* SwiftUIIntrospect */ = {
isa = XCSwiftPackageProductDependency;
package = 205D81A42C71B9D70047C1CC /* XCRemoteSwiftPackageReference "swiftui-introspect" */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "3af81fba53312a9bf207661172fc1fe957ee2d72891f7537035a4ae61ae39934",
"originHash" : "f0fb8ceb3ffd5128d02593ebef3a373aa7fe9597383061f9f65348fd33476726",
"pins" : [
{
"identity" : "async-swift-ui",
Expand Down Expand Up @@ -33,8 +33,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/SimplyDanny/SwiftLintPlugins",
"state" : {
"revision" : "6c3d6c32a37224179dc290f21e03d1238f3d963b",
"version" : "0.56.2"
"revision" : "7c80ce6f142164b0201871e580b021d1b2c69804",
"version" : "0.57.0"
}
},
{
Expand All @@ -46,22 +46,13 @@
"version" : "1.3.0"
}
},
{
"identity" : "swiftui-shimmer",
"kind" : "remoteSourceControl",
"location" : "https://github.com/markiv/SwiftUI-Shimmer",
"state" : {
"revision" : "0226e21f9bf355d40e07e5f5e1c33679d50e167f",
"version" : "1.5.1"
}
},
{
"identity" : "vrckit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/makinosp/vrckit",
"state" : {
"branch" : "develop",
"revision" : "bf2facec1f9c338ee67c6469c5098b7e5c2ebd09"
"revision" : "1f1df4f2d04d2a81d0ee0d9a8753021f967909b9"
}
}
],
Expand Down
3 changes: 1 addition & 2 deletions harmonie/Components/SquareURLImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import NukeUI
import Shimmer
import SwiftUI

struct SquareURLImage: View {
Expand All @@ -27,9 +26,9 @@ struct SquareURLImage: View {

var placeholder: some View {
rect
.fill(.gray)
.frame(width: frameWidth, height: frameWidth * 3/4)
.redacted(reason: .placeholder)
.shimmering()
}

var body: some View {
Expand Down
21 changes: 21 additions & 0 deletions harmonie/Protocols/InstanceServicePresentable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// InstanceServicePresentable.swift
// Harmonie
//
// Created by makinosp on 2024/09/09.
//

import VRCKit

protocol InstanceServicePresentable {
var appVM: AppViewModel { get }
}

extension InstanceServicePresentable {
@MainActor
var instanceService: InstanceServiceProtocol {
appVM.isDemoMode
? InstancePreviewService(client: appVM.client)
: InstanceService(client: appVM.client)
}
}
21 changes: 21 additions & 0 deletions harmonie/Protocols/UserServicePresentable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// UserServicePresentable.swift
// Harmonie
//
// Created by makinosp on 2024/09/09.
//

import VRCKit

protocol UserServicePresentable {
var appVM: AppViewModel { get }
}

extension UserServicePresentable {
@MainActor
var userService: UserServiceProtocol {
appVM.isDemoMode
? UserPreviewService(client: appVM.client)
: UserService(client: appVM.client)
}
}
2 changes: 1 addition & 1 deletion harmonie/Utils/KeychainUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class KeychainUtil {
var item: CFTypeRef?
let status = SecItemCopyMatching(query, &item)
guard status == errSecSuccess, let passwordData = item as? Data else { return nil }
return String(decoding: passwordData, as: UTF8.self)
return String(data: passwordData, encoding: .utf8)
}

func deletePassword(for account: String) -> Bool {
Expand Down
18 changes: 8 additions & 10 deletions harmonie/ViewModels/AppViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
import Observation
import VRCKit

@Observable
@Observable @MainActor
final class AppViewModel {
var user: User?
var step: Step = .initializing
Expand All @@ -25,7 +25,7 @@ final class AppViewModel {
/// Check the authentication status of the user,
/// fetch the user information, and perform the initialization process.
/// - Returns: Depending on the status, either `loggingIn` or `done` is returned.
func setup(service: any AuthenticationServiceProtocol) async -> Step {
func setup(service: AuthenticationServiceProtocol) async -> Step {
// check local data
guard !client.cookieManager.cookies.isEmpty else {
return .loggingIn
Expand All @@ -44,12 +44,7 @@ final class AppViewModel {
}
}

func login(
service: any AuthenticationServiceProtocol,
username: String,
password: String,
isSavedOnKeyChain: Bool
) async -> VerifyType? {
func login(username: String, password: String, isSavedOnKeyChain: Bool) async -> VerifyType? {
if username == "demo" && password == "demo" {
isDemoMode = true
} else {
Expand All @@ -58,6 +53,9 @@ final class AppViewModel {
if isSavedOnKeyChain {
_ = KeychainUtil.shared.savePassword(password, for: username)
}
let service = isDemoMode
? AuthenticationPreviewService(client: client)
: AuthenticationService(client: client)
do {
switch try await service.loginUserInfo() {
case let verifyType as VerifyType:
Expand All @@ -74,7 +72,7 @@ final class AppViewModel {
}

func verifyTwoFA(
service: any AuthenticationServiceProtocol,
service: AuthenticationServiceProtocol,
verifyType: VerifyType?,
code: String
) async {
Expand All @@ -96,7 +94,7 @@ final class AppViewModel {
}
}

func logout(service: any AuthenticationServiceProtocol) async {
func logout(service: AuthenticationServiceProtocol) async {
do {
try await service.logout()
reset()
Expand Down
4 changes: 2 additions & 2 deletions harmonie/ViewModels/FavoriteViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import VRCKit

/// View model for managing favorite groups and their associated details.
/// Acts as an interface between the UI and backend services for handling favorite group operations.
@Observable
@Observable @MainActor
final class FavoriteViewModel {
typealias FavoriteFriend = (favoriteGroupId: String, friends: [Friend])
var favoriteGroups: [FavoriteGroup] = []
Expand Down Expand Up @@ -123,7 +123,7 @@ final class FavoriteViewModel {
}
}

func fetchFavoritedWorlds(service: any WorldServiceProtocol) async throws {
func fetchFavoritedWorlds(service: WorldServiceProtocol) async throws {
favoriteWorlds = try await service.fetchFavoritedWorlds()
}
}
Expand Down
2 changes: 1 addition & 1 deletion harmonie/ViewModels/FriendViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Observation
import VRCKit

@Observable
@Observable @MainActor
final class FriendViewModel {
var onlineFriends: [Friend] = []
var offlineFriends: [Friend] = []
Expand Down
4 changes: 2 additions & 2 deletions harmonie/ViewModels/ProfileEditViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Observation
import VRCKit

@Observable
@Observable @MainActor
final class ProfileEditViewModel {
var editingUserInfo: EditableUserInfo
@ObservationIgnored private let id: String
Expand All @@ -18,7 +18,7 @@ final class ProfileEditViewModel {
id = user.id
}

func saveProfile(service: any UserServiceProtocol) async throws {
func saveProfile(service: UserServiceProtocol) async throws {
try await service.updateUser(
id: id,
editedInfo: editingUserInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ extension AuthenticationView {
loginFields
loginButton("Login") {
verifyType = await appVM.login(
service: authenticationService,
username: username,
password: password,
isSavedOnKeyChain: isSavedOnKeyChain
Expand Down
Loading

0 comments on commit 59f5852

Please sign in to comment.