This commit is contained in:
Vladimir Dubovik
2025-05-22 16:16:33 +03:00
parent d32511db39
commit 2204bb9fe0
7 changed files with 61 additions and 3 deletions

View File

@ -12,6 +12,7 @@ struct ContentView: View {
@State private var isTabBarHidden = false @State private var isTabBarHidden = false
@ObservedObject var vm: ScheduleViewModel @ObservedObject var vm: ScheduleViewModel
@ObservedObject var networkMonitor: NetworkMonitor @ObservedObject var networkMonitor: NetworkMonitor
@StateObject private var navigationManager = NavigationManager()
var body: some View { var body: some View {
ZStack (alignment: .bottom) { ZStack (alignment: .bottom) {
TabView(selection: $selectedTab) { TabView(selection: $selectedTab) {
@ -32,7 +33,7 @@ struct ContentView: View {
SettingsView(vm: vm, networkMonitor: networkMonitor) SettingsView(vm: vm, networkMonitor: networkMonitor)
.tag(TabBarModel.settings) .tag(TabBarModel.settings)
} }
TabBarView(selectedTab: $selectedTab) TabBarView(selectedTab: $selectedTab, navigationManager: navigationManager)
} }
.alert(isPresented: $vm.isShowingAlertForIncorrectSingleGroup, error: vm.errorInNetworkForSingleGroup) { error in .alert(isPresented: $vm.isShowingAlertForIncorrectSingleGroup, error: vm.errorInNetworkForSingleGroup) { error in
Button("ОК") { Button("ОК") {

View File

@ -41,8 +41,18 @@ struct FavGroupsView: View {
} }
} }
} }
.navigationBarBackButtonHidden(true) // Скрываем стандартную кнопку "Назад" .navigationBarBackButtonHidden(true)
.background(Color("background")) .background(Color("background"))
// Жест для возврата на страницу настроек
.simultaneousGesture(
DragGesture(minimumDistance: 20, coordinateSpace: .local)
.onEnded { value in
// Проверяем, что свайп начинается у левого края и идёт вправо
if value.startLocation.x < 20 && value.translation.width > 80 {
dismiss()
}
}
)
.toolbar { .toolbar {
ToolbarItem(placement: .topBarLeading) { ToolbarItem(placement: .topBarLeading) {
Button(action: { Button(action: {

View File

@ -40,8 +40,17 @@ struct FavVPKView: View {
} }
} }
} }
.navigationBarBackButtonHidden(true) // Скрываем стандартную кнопку "Назад" .navigationBarBackButtonHidden(true)
.background(Color("background")) .background(Color("background"))
.simultaneousGesture(
DragGesture(minimumDistance: 20, coordinateSpace: .local)
.onEnded { value in
// Проверяем, что свайп начинается у левого края и идёт вправо
if value.startLocation.x < 20 && value.translation.width > 80 {
dismiss()
}
}
)
.toolbar { .toolbar {
ToolbarItem(placement: .topBarLeading) { ToolbarItem(placement: .topBarLeading) {
Button(action: { Button(action: {

View File

@ -121,6 +121,9 @@ struct SelectingGroupView: View {
saveScheduleForGroupToMemory(withName: item.name) saveScheduleForGroupToMemory(withName: item.name)
vm.nameToHtml[item.name] = "" vm.nameToHtml[item.name] = ""
vm.addGroupToFilteringArray(group: item.name) vm.addGroupToFilteringArray(group: item.name)
if vm.filteringGroups.count == 2 {
vm.showOnlyChoosenGroup = vm.filteringGroups[1]
}
vm.fetchWeekSchedule() vm.fetchWeekSchedule()
self.isLoading = false self.isLoading = false
self.text = "" self.text = ""
@ -158,6 +161,13 @@ struct SelectingGroupView: View {
} }
} }
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.gesture(
DragGesture().onEnded { value in
if value.startLocation.x < 50 && value.translation.width > 80 {
dismiss()
}
}
)
} }
} }

View File

@ -121,6 +121,13 @@ struct SelectingVPKView: View {
} }
} }
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.gesture(
DragGesture().onEnded { value in
if value.startLocation.x < 50 && value.translation.width > 80 {
dismiss()
}
}
)
} }
} }

View File

@ -9,6 +9,7 @@ import SwiftUI
struct TabBarView: View { struct TabBarView: View {
@Binding var selectedTab: TabBarModel @Binding var selectedTab: TabBarModel
@ObservedObject var navigationManager: NavigationManager
@Namespace private var animation @Namespace private var animation
var body: some View { var body: some View {
VStack { VStack {
@ -36,6 +37,10 @@ struct TabBarView: View {
var content: some View { var content: some View {
ForEach(TabBarModel.allCases, id: \.rawValue) { tab in ForEach(TabBarModel.allCases, id: \.rawValue) { tab in
Button { Button {
if selectedTab == tab {
// Если таб уже выбран, сбрасываем навигацию
navigationManager.popToRoot()
}
selectedTab = tab selectedTab = tab
} label: { } label: {
VStack (alignment: .center) { VStack (alignment: .center) {

View File

@ -0,0 +1,16 @@
//
// NavigationManager.swift
// Schedule-ICTIS
//
// Created by Mironov Egor on 21.05.2025.
//
import SwiftUI
class NavigationManager: ObservableObject {
@Published var path = NavigationPath()
func popToRoot() {
path.removeLast(path.count)
}
}