Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
54 changes: 47 additions & 7 deletions MacMagazine/MacMagazine/MainApp/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -37,7 +70,14 @@ struct MainView: View {
}
}

// MARK: - Methods -

private extension MainView {
}

#if DEBUG
// MARK: - Preview -

import StorageLibrary

#Preview {
Expand Down
35 changes: 35 additions & 0 deletions MacMagazine/MacMagazine/MainApp/NavigationState.swift
Original file line number Diff line number Diff line change
@@ -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
}
}
}