Skip to content

Commit

Permalink
Merge pull request #210 from makinosp/develop
Browse files Browse the repository at this point in the history
update: bump up to 0.10.0
  • Loading branch information
makinosp authored Nov 15, 2024
2 parents ab40564 + e54bdaa commit c61bb78
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 19 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.10;
MARKETING_VERSION = 0.10.0;
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.10;
MARKETING_VERSION = 0.10.0;
PRODUCT_BUNDLE_IDENTIFIER = jp.mknn.harmonie;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
3 changes: 3 additions & 0 deletions harmonie/ViewModels/FavoriteViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ final class FavoriteViewModel {
var favoriteGroups: [FavoriteGroup] = []
var favoriteFriends: [FavoriteFriend] = []
var favoriteWorlds: [FavoriteWorld] = []
var isFetchingFavoriteFriends = true

/// Filters and returns the favorite groups of a specific type.
/// - Parameter type: The `FavoriteType` to filter the favorite groups by.
Expand Down Expand Up @@ -66,6 +67,8 @@ final class FavoriteViewModel {
/// if a corresponding friend is found; returns `nil` otherwise.
/// - Throws: An error if the service encounters an issue while fetching favorite groups or favorite details.
func fetchFavoriteFriends(service: FavoriteServiceProtocol, friendFinder: (Favorite) -> Friend?) async throws {
defer { isFetchingFavoriteFriends = false }
isFetchingFavoriteFriends = true
favoriteGroups = try await service.listFavoriteGroups()
let favoriteDetails = try await service.fetchFavoriteList(favoriteGroups: favoriteGroups, type: .friend)
let favoriteDetailsOfFriends = favoriteDetails.filter { $0.allFavoritesAre(.friend) }
Expand Down
12 changes: 6 additions & 6 deletions harmonie/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ struct ContentView: View {
switch appVM.step {
case .initializing:
ProgressScreen()
.task {
appVM.step = await appVM.setup(service: appVM.services.authenticationService)
}
.errorAlert()
.task { await setUpTask() }
case .loggingIn:
LoginView()
.errorAlert()
case .done:
MainTabView()
.errorAlert()
}
} action: { geometry in
setScreenSize(geometry)
}
.errorAlert()
}

private func setUpTask() async {
appVM.step = await appVM.setup(service: appVM.services.authenticationService)
}

private func setScreenSize(_ geometry: GeometryProxy) {
Expand Down
8 changes: 7 additions & 1 deletion harmonie/Views/Favorite/FavoritesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ struct FavoritesView: View {
}
}
.overlay {
if isSelectedEmpty {
if isFetching {
ProgressView()
} else if isSelectedEmpty {
ContentUnavailableView {
Label("No Favorites", systemImage: IconSet.favorite.systemName)
}
Expand All @@ -47,6 +49,10 @@ struct FavoritesView: View {
}
}

private var isFetching: Bool {
friendVM.isFetchingAllFriends || favoriteVM.isFetchingFavoriteFriends
}

@ViewBuilder private var toolbarTitleMenu: some View {
Picker("", selection: $segment) {
Label("All", systemImage: IconSet.favoriteSquares.systemName)
Expand Down
6 changes: 5 additions & 1 deletion harmonie/Views/Friend/FriendsListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct FriendsListView: View {
}

@ViewBuilder private var overlayView: some View {
if friendVM.isProcessingFilter {
if isProcessing {
ProgressView()
} else if friendVM.filterResultFriends.isEmpty {
if friendVM.isEmptyAllFilters {
Expand All @@ -59,4 +59,8 @@ struct FriendsListView: View {
}
}
}

private var isProcessing: Bool {
friendVM.isProcessingFilter || friendVM.isFetchingAllFriends
}
}
2 changes: 0 additions & 2 deletions harmonie/Views/Location/LocationsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ struct LocationsView: View {
inPrivateInstance
}
}
.environment(\.defaultMinListRowHeight, 80)
.overlay {
if friendVM.isContentUnavailable {
ContentUnavailableView {
Expand Down Expand Up @@ -86,7 +85,6 @@ struct LocationsView: View {
}
}
}
.safeAreaPadding(.top, 20)
.background(Color(.systemGroupedBackground))
.setColumn(appVM.screenSize)
}
Expand Down
17 changes: 10 additions & 7 deletions harmonie/Views/MainTabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ struct MainTabView: View {
Task { await fetchFriendsTask() }
Task { await fetchFavoritesTask() }
}
.onChange(of: scenePhase) {
scenePhaseHandler(scenePhase)
.onChange(of: scenePhase) { before, after in
changedScenePhaseHandler(before, after)
}
.onChange(of: favoriteVM.favoriteFriends) {
friendVM.favoriteFriends = favoriteVM.favoriteFriends
Expand All @@ -51,15 +51,15 @@ extension MainTabViewSegment {
}
}

@MainActor
extension MainTabView {
private func scenePhaseHandler(_ scenePhase: ScenePhase) {
switch scenePhase {
case .active:
private func changedScenePhaseHandler(_ before: ScenePhase, _ after: ScenePhase) {
switch (before, after) {
case (.background, .inactive):
print("Restoring Data")
restoreUserData()
Task { await fetchFriendsTask() }
Task { await fetchFavoritesTask() }
case .background, .inactive:
case (.active, .inactive):
guard let user = appVM.user else { return }
userData = user.rawValue
default: break
Expand All @@ -70,7 +70,10 @@ extension MainTabView {
guard let user = User(rawValue: userData) else { return }
appVM.user = user
}
}

@MainActor
extension MainTabView {
private var tabViewLegacy: some View {
TabView(selection: $selection) {
ForEach(MainTabViewSegment.allCases) { tabSegment in
Expand Down

0 comments on commit c61bb78

Please sign in to comment.