diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml index 923dc328..5731c431 100644 --- a/.github/workflows/pr-validation.yml +++ b/.github/workflows/pr-validation.yml @@ -93,14 +93,8 @@ jobs: echo "Available simulators:" echo "$SIMULATORS" - # Prefer iPhone 15 Pro, then iPhone 15, then iPhone 14 Pro, then any available iPhone - SIMULATOR=$(echo "$SIMULATORS" | grep -i "iPhone 15 Pro" | head -n 1) - if [ -z "$SIMULATOR" ]; then - SIMULATOR=$(echo "$SIMULATORS" | grep -i "iPhone 15" | head -n 1) - fi - if [ -z "$SIMULATOR" ]; then - SIMULATOR=$(echo "$SIMULATORS" | grep -i "iPhone 14 Pro" | head -n 1) - fi + # Prefer latest iPhone Pro models, then any available iPhone + SIMULATOR=$(echo "$SIMULATORS" | grep -i "iPhone.*Pro" | head -n 1) if [ -z "$SIMULATOR" ]; then SIMULATOR=$(echo "$SIMULATORS" | grep -i "iPhone" | head -n 1) fi @@ -123,9 +117,12 @@ jobs: echo "Running tests on ${{ steps.detect-simulator.outputs.simulator_name }} (iOS ${{ steps.detect-simulator.outputs.simulator_os }})" xcodebuild test \ + -project MacMagazine/MacMagazine.xcodeproj \ -scheme MacMagazine \ -testPlan MacMagazine \ - -destination "platform=iOS Simulator,name=${{ steps.detect-simulator.outputs.simulator_name }},OS=${{ steps.detect-simulator.outputs.simulator_os }}" \ + -destination "platform=iOS Simulator,name=${{ steps.detect-simulator.outputs.simulator_name }}" \ + -skipPackagePluginValidation \ + -skipMacroValidation \ -resultBundlePath TestResults \ | xcpretty && exit ${PIPESTATUS[0]} diff --git a/MacMagazine/Features/SettingsLibrary/Sources/SettingsLibrary/Definitions/AppDefinitions.swift b/MacMagazine/Features/SettingsLibrary/Sources/SettingsLibrary/Definitions/AppDefinitions.swift index 1fc73712..7d82a60d 100644 --- a/MacMagazine/Features/SettingsLibrary/Sources/SettingsLibrary/Definitions/AppDefinitions.swift +++ b/MacMagazine/Features/SettingsLibrary/Sources/SettingsLibrary/Definitions/AppDefinitions.swift @@ -2,18 +2,12 @@ import Foundation public enum AppTabs: String, CaseIterable, Codable, Hashable { - // MARK: - iPhone Tabs - - case live = "MM Live" case news = "Notícias" case social = "Mídias" case settings = "Ajustes" case search = "Busca" - // MARK: - iPad Sidebar - - - // MARK: - Common properties - - public var icon: String { switch self { case .live: "antenna.radiowaves.left.and.right" @@ -33,10 +27,29 @@ public enum News: String, CaseIterable, Codable, Hashable { case reviews = "Reviews" case rumors = "Rumores" case tutoriais = "Tutoriais" + + public var icon: String { + switch self { + case .all, .news: "antenna.radiowaves.left.and.right" + case .highlights: "point.3.filled.connected.trianglepath.dotted" + case .appletv: "gearshape" + case .reviews: "magnifyingglass" + case .rumors: "magnifyingglass" + case .tutoriais: "magnifyingglass" + } + } } public enum Social: String, CaseIterable, Codable, Hashable { case videos = "Videos" case podcast = "MM no Ar" case instagram = "Instagram" + + public var icon: String { + switch self { + case .videos: "antenna.radiowaves.left.and.right" + case .podcast: "newspaper" + case .instagram: "point.3.filled.connected.trianglepath.dotted" + } + } } diff --git a/MacMagazine/MacMagazine.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/MacMagazine/MacMagazine.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 2d28f6c0..fa73a91a 100644 --- a/MacMagazine/MacMagazine.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/MacMagazine/MacMagazine.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -106,7 +106,7 @@ "location" : "https://github.com/cassio-rossi/Libraries.git", "state" : { "branch" : "main", - "revision" : "34148feae97e1fa18af60b34c91a954b64669758" + "revision" : "4944b61a8acd36a26a407338ba6bf32e38035ab9" } }, { diff --git a/MacMagazine/MacMagazine.xcodeproj/project.xcworkspace/xcuserdata/cassiorossi.xcuserdatad/UserInterfaceState.xcuserstate b/MacMagazine/MacMagazine.xcodeproj/project.xcworkspace/xcuserdata/cassiorossi.xcuserdatad/UserInterfaceState.xcuserstate index 47235216..ac4abd0b 100644 Binary files a/MacMagazine/MacMagazine.xcodeproj/project.xcworkspace/xcuserdata/cassiorossi.xcuserdatad/UserInterfaceState.xcuserstate and b/MacMagazine/MacMagazine.xcodeproj/project.xcworkspace/xcuserdata/cassiorossi.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/MacMagazine/MacMagazine/MainApp/MainView.swift b/MacMagazine/MacMagazine/MainApp/MainView.swift index 427371bf..6a2b1d7d 100644 --- a/MacMagazine/MacMagazine/MainApp/MainView.swift +++ b/MacMagazine/MacMagazine/MainApp/MainView.swift @@ -4,29 +4,62 @@ import SwiftUI import UIComponentsLibrary struct MainView: View { + private var navigationState = NavigationState() + @Environment(\.horizontalSizeClass) private var horizontalSizeClass @Environment(\.theme) private var theme: ThemeColor @EnvironmentObject private var viewModel: MainViewModel @State private var searchText: String = "" + private var shouldUseSidebar: Bool { + horizontalSizeClass == .regular + } + var body: some View { ZStack { theme.main.background.color .edgesIgnoringSafeArea(.all) - TabView(selection: $viewModel.tab) { - ForEach(viewModel.settingsViewModel.tabs, id: \.self) { tab in - Tab(tab.rawValue, systemImage: tab.icon, value: tab, role: tab == .search ? .search : .none) { - AnyView(contentView(for: tab)) - } + content + .tint(theme.tertiary.background.color) + } + .animation(.easeInOut(duration: 0.3), value: shouldUseSidebar) + .onChange(of: horizontalSizeClass) { old, new in + navigationState.navigate(from: old, to: new) + } + } +} + +// MARK: - Views - + +private extension MainView { + @ViewBuilder + var content: some View { + if shouldUseSidebar { + sideBarContentView + } else { + tabContentView + } + } + + @ViewBuilder + var sideBarContentView: some View { + contentView(for: .social) + } + + @ViewBuilder + var tabContentView: some View { + TabView(selection: $viewModel.tab) { + ForEach(viewModel.settingsViewModel.tabs, id: \.self) { tab in + Tab(tab.rawValue, systemImage: tab.icon, value: tab, role: tab == .search ? .search : .none) { + AnyView(contentView(for: tab)) } } - .tint(theme.tertiary.background.color) } } @ViewBuilder - private func contentView(for tab: AppTabs) -> some View { + func contentView(for tab: AppTabs) -> some View { switch tab { case .live: Text("MMLiveView()") case .news: NewsView(storage: viewModel.storage) @@ -37,7 +70,14 @@ struct MainView: View { } } +// MARK: - Methods - + +private extension MainView { +} + #if DEBUG +// MARK: - Preview - + import StorageLibrary #Preview { diff --git a/MacMagazine/MacMagazine/MainApp/NavigationState.swift b/MacMagazine/MacMagazine/MainApp/NavigationState.swift new file mode 100644 index 00000000..fd8e2060 --- /dev/null +++ b/MacMagazine/MacMagazine/MainApp/NavigationState.swift @@ -0,0 +1,35 @@ +import Combine +import SettingsLibrary +import SwiftUI + +@Observable +class NavigationState { + var selectedItem: any CaseIterable = AppTabs.news + var navigationPath = NavigationPath() + + func navigate(to item: any CaseIterable) { + selectedItem = item + } + + func navigate(from old: UserInterfaceSizeClass?, to new: UserInterfaceSizeClass?) { + switch new { + case .regular: // tabbar -> sidebar + switch selectedItem { + case AppTabs.social: + selectedItem = Social.videos + + default: break + } + + case .compact: // sidebar -> tabbar + switch selectedItem { + case Social.videos, Social.podcast, Social.instagram: + selectedItem = AppTabs.social + + default: break + } + + default: break + } + } +}