Now fonts are correct
This commit is contained in:
parent
4ee81cf2ea
commit
06416138d9
@ -16,9 +16,9 @@ struct CreatedClassView: View {
|
||||
HStack(spacing: 10) {
|
||||
VStack {
|
||||
Text(getTimeString(_class.starttime))
|
||||
.font(.system(size: 15, weight: .regular))
|
||||
.font(.custom("Montserrat-Regular", size: 15))
|
||||
Text(getTimeString(_class.endtime))
|
||||
.font(.system(size: 15, weight: .regular))
|
||||
.font(.custom("Montserrat-Regular", size: 15))
|
||||
}
|
||||
.padding(.top, 7)
|
||||
.padding(.bottom, 7)
|
||||
@ -30,7 +30,7 @@ struct CreatedClassView: View {
|
||||
.padding(.bottom, 7)
|
||||
.foregroundColor(_class.important ? Color("redForImportant") : onlineOrNot(_class.online))
|
||||
Text(getSubjectName(_class.subject, _class.professor, _class.auditory))
|
||||
.font(.system(size: 18, weight: .regular))
|
||||
.font(.custom("Montserrat-Regular", size: 18))
|
||||
.padding(.top, 7)
|
||||
.padding(.bottom, 7)
|
||||
Spacer()
|
||||
|
@ -16,9 +16,9 @@ struct AuditoryFieldView: View {
|
||||
Image(systemName: "mappin.and.ellipse")
|
||||
.foregroundColor(Color.gray)
|
||||
.padding(.leading, 12)
|
||||
.padding(.trailing, 7)
|
||||
.padding(.trailing, 14)
|
||||
TextField(labelForField, text: $text)
|
||||
.font(.system(size: 18, weight: .regular))
|
||||
.font(.custom("Montserrat-Regular", size: 18))
|
||||
.disableAutocorrection(true)
|
||||
.submitLabel(.done)
|
||||
.focused($isFocused)
|
||||
|
@ -14,6 +14,7 @@ struct CommentFieldView: View {
|
||||
var body: some View {
|
||||
HStack {
|
||||
TextField("Комментарий", text: $textForComment)
|
||||
.font(.custom("Montserrat-Regular", size: 18))
|
||||
.submitLabel(.done)
|
||||
.multilineTextAlignment(.leading)
|
||||
.focused($isFocused)
|
||||
|
@ -18,7 +18,7 @@ struct ProfessorFieldView: View {
|
||||
.padding(.leading, 12)
|
||||
.padding(.trailing, 7)
|
||||
TextField(labelForField, text: $text)
|
||||
.font(.system(size: 18, weight: .regular))
|
||||
.font(.custom("Montserrat-Regular", size: 18))
|
||||
.disableAutocorrection(true)
|
||||
.submitLabel(.done)
|
||||
.focused($isFocused)
|
||||
|
@ -19,16 +19,17 @@ struct StartEndTimeFieldView: View {
|
||||
Image(systemName: imageName)
|
||||
.foregroundColor(isIncorrectDate ? .red : Color("grayForFields"))
|
||||
.padding(.leading, 12)
|
||||
.padding(.trailing, 5)
|
||||
|
||||
if !isTimeSelected || isIncorrectDate {
|
||||
Text(text)
|
||||
.font(.system(size: 17, weight: .regular))
|
||||
.font(.custom("Montserrat-Regular", size: 17))
|
||||
.foregroundColor(.gray.opacity(0.5))
|
||||
}
|
||||
else {
|
||||
Text("\(selectedTime, formatter: timeFormatter)")
|
||||
.foregroundColor(isIncorrectDate ? .red : .black)
|
||||
.font(.system(size: 17, weight: .medium))
|
||||
.font(.custom("Montserrat-Medium", size: 17))
|
||||
.padding(.trailing, 10)
|
||||
}
|
||||
Spacer()
|
||||
|
@ -3,7 +3,7 @@
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 16.12.2024.
|
||||
//
|
||||
// КТбо2-6
|
||||
|
||||
import SwiftUI
|
||||
|
||||
@ -17,9 +17,9 @@ struct SubjectFieldView: View {
|
||||
Image(systemName: "book")
|
||||
.foregroundColor(Color.gray)
|
||||
.padding(.leading, 12)
|
||||
.padding(.trailing, 7)
|
||||
.padding(.trailing, 9)
|
||||
TextField(labelForField, text: $text)
|
||||
.font(.system(size: 18, weight: .regular))
|
||||
.font(.custom("Montserrat-Regular", size: 18))
|
||||
.disableAutocorrection(true)
|
||||
.submitLabel(.done)
|
||||
.focused($isFocused)
|
||||
@ -33,7 +33,7 @@ struct SubjectFieldView: View {
|
||||
Group {
|
||||
if isShowingSubjectFieldRed {
|
||||
Text("Поле должно быть заполнено!")
|
||||
.font(.system(size: 18, weight: .regular))
|
||||
.font(.custom("Montserrat-Regular", size: 18))
|
||||
.foregroundColor(.red)
|
||||
.frame(width: 290)
|
||||
.padding(.leading, -42)
|
||||
|
@ -12,10 +12,16 @@ struct MainView: View {
|
||||
@State private var isShowingMonthSlider: Bool = false
|
||||
@ObservedObject var vm: ScheduleViewModel
|
||||
@FocusState private var isFocusedSearchBar: Bool
|
||||
@State private var isScrolling: Bool = false
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
SearchBarView(text: $searchText, isFocused: _isFocusedSearchBar, vm: vm)
|
||||
.onChange(of: isScrolling, initial: false) { oldValue, newValue in
|
||||
if newValue && isScrolling {
|
||||
isFocusedSearchBar = false
|
||||
}
|
||||
}
|
||||
|
||||
if (vm.isFirstStartOffApp && vm.isLoading) {
|
||||
LoadingView(isLoading: $vm.isLoading)
|
||||
@ -25,7 +31,7 @@ struct MainView: View {
|
||||
}
|
||||
else {
|
||||
CurrentDateView()
|
||||
ScheduleView(vm: vm)
|
||||
ScheduleView(vm: vm, isScrolling: $isScrolling)
|
||||
}
|
||||
}
|
||||
.alert(isPresented: $vm.isShowingAlertForIncorrectGroup, error: vm.errorInNetwork) { error in
|
||||
@ -45,14 +51,14 @@ struct MainView: View {
|
||||
HStack {
|
||||
VStack (alignment: .leading, spacing: 0) {
|
||||
Text(vm.selectedDay.format("EEEE"))
|
||||
.font(.system(size: 40, weight: .semibold))
|
||||
.font(.custom("Montserrat-SemiBold", size: 40))
|
||||
.foregroundStyle(.black)
|
||||
HStack (spacing: 5) {
|
||||
Text(vm.selectedDay.format("dd"))
|
||||
.font(.system(size: 20, weight: .bold))
|
||||
.font(.custom("Montserrat-Bold", size: 20))
|
||||
.foregroundStyle(Color("grayForDate"))
|
||||
Text(vm.selectedDay.format("MMMM"))
|
||||
.font(.system(size: 20, weight: .bold))
|
||||
.font(.custom("Montserrat-Bold", size: 20))
|
||||
.foregroundStyle(Color("grayForDate"))
|
||||
Spacer()
|
||||
Button(action: {
|
||||
@ -62,7 +68,7 @@ struct MainView: View {
|
||||
}) {
|
||||
HStack(spacing: 2) {
|
||||
Text(isShowingMonthSlider ? "Свернуть" : "Развернуть")
|
||||
.font(.system(size: 16, weight: .light))
|
||||
.font(.custom("Montserrat-Light", size: 16))
|
||||
.foregroundStyle(Color.blue)
|
||||
Image(isShowingMonthSlider ? "arrowup" : "arrowdown")
|
||||
.resizable()
|
||||
|
@ -13,6 +13,7 @@ struct NoScheduleView: View {
|
||||
ScrollView (showsIndicators: false) {
|
||||
Text("Пока расписания нет")
|
||||
.padding(.top, 20)
|
||||
.font(.custom("Montserrat-Regular", size: 15))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by Mironov Egor on 05.12.2024.
|
||||
//
|
||||
// ктбо2-6
|
||||
|
||||
import SwiftUI
|
||||
|
||||
@ -11,6 +11,7 @@ struct ScheduleView: View {
|
||||
@ObservedObject var vm: ScheduleViewModel
|
||||
@FetchRequest(fetchRequest: ClassModel.all()) private var classes //Делаем запрос в CoreData и получаем список сохраненных пар
|
||||
@State private var selectedClass: ClassModel? = nil
|
||||
@Binding var isScrolling: Bool
|
||||
var provider = ClassProvider.shared
|
||||
var body: some View {
|
||||
if vm.isLoading {
|
||||
@ -30,9 +31,11 @@ struct ScheduleView: View {
|
||||
HStack(spacing: 10) {
|
||||
VStack {
|
||||
Text(convertTimeString(vm.classes[1][lessonIndex])[0])
|
||||
.font(.system(size: 15, weight: .regular))
|
||||
.font(.custom("Montserrat-Medium", size: 15))
|
||||
.padding(.bottom, 1)
|
||||
Text(convertTimeString(vm.classes[1][lessonIndex])[1])
|
||||
.font(.system(size: 15, weight: .regular))
|
||||
.font(.custom("Montserrat-Medium", size: 15))
|
||||
.padding(.top, 1)
|
||||
}
|
||||
.padding(.top, 7)
|
||||
.padding(.bottom, 7)
|
||||
@ -44,9 +47,10 @@ struct ScheduleView: View {
|
||||
.padding(.bottom, 7)
|
||||
.foregroundColor(getColorForClass(lesson))
|
||||
Text(lesson)
|
||||
.font(.system(size: 18, weight: .regular))
|
||||
.padding(.top, 7)
|
||||
.padding(.bottom, 7)
|
||||
.font(.custom("Montserrat-Regular", size: 17))
|
||||
.lineSpacing(3)
|
||||
.padding(.top, 9)
|
||||
.padding(.bottom, 9)
|
||||
Spacer()
|
||||
}
|
||||
.frame(maxWidth: UIScreen.main.bounds.width - 40, maxHeight: 230)
|
||||
@ -70,6 +74,16 @@ struct ScheduleView: View {
|
||||
.padding(.bottom, 100)
|
||||
.padding(.top, 30)
|
||||
}
|
||||
.onPreferenceChange(ViewOffsetKey.self) { offset in
|
||||
if offset > 0 {
|
||||
isScrolling = true
|
||||
print("Сейчас скролл")
|
||||
} else {
|
||||
isScrolling = false
|
||||
print("Scrolling ended")
|
||||
}
|
||||
}
|
||||
.coordinateSpace(name: "scroll")
|
||||
VStack {
|
||||
LinearGradient(gradient: Gradient(colors: [Color("background").opacity(0.95), Color.white.opacity(0.1)]), startPoint: .top, endPoint: .bottom)
|
||||
}
|
||||
@ -91,6 +105,14 @@ struct ScheduleView: View {
|
||||
}
|
||||
}
|
||||
|
||||
struct ViewOffsetKey: PreferenceKey {
|
||||
typealias Value = CGFloat
|
||||
static var defaultValue = CGFloat.zero
|
||||
static func reduce(value: inout Value, nextValue: () -> Value) {
|
||||
value += nextValue()
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
ContentView()
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ struct CreateEditClassView: View {
|
||||
.padding(.bottom, 10)
|
||||
HStack {
|
||||
Text("Тип")
|
||||
.font(.custom("Montserrat-Medium", size: 17))
|
||||
Spacer()
|
||||
Picker("Тип", selection: $vm._class.online, content: {
|
||||
ForEach(MockData.onlineOrOffline, id: \.self) {
|
||||
@ -72,14 +73,14 @@ struct CreateEditClassView: View {
|
||||
Image(systemName: "calendar")
|
||||
.foregroundColor(Color.gray)
|
||||
.padding(.leading, 12)
|
||||
.padding(.trailing, 7)
|
||||
.padding(.trailing, 5)
|
||||
Text("Дата")
|
||||
.foregroundColor(Color("grayForFields").opacity(0.5))
|
||||
.font(.system(size: 18, weight: .regular))
|
||||
.font(.custom("Montserrat-Regular", size: 18))
|
||||
Spacer()
|
||||
Text("\(vm._class.day, formatter: dateFormatter)")
|
||||
.foregroundColor(.black)
|
||||
.font(.system(size: 18, weight: .medium))
|
||||
.font(.custom("Montserrat-Medium", size: 18))
|
||||
.padding(.trailing, 20)
|
||||
}
|
||||
.frame(height: 40)
|
||||
@ -127,6 +128,7 @@ struct CreateEditClassView: View {
|
||||
.frame(height: 40)
|
||||
.padding(.bottom, 10)
|
||||
Toggle("Пометить как важную", isOn: $vm._class.important)
|
||||
.font(.custom("Montserrat-Medium", size: 17))
|
||||
.frame(height: 40)
|
||||
.padding(.horizontal)
|
||||
.background(
|
||||
@ -137,6 +139,7 @@ struct CreateEditClassView: View {
|
||||
|
||||
HStack {
|
||||
Text("Напоминанние")
|
||||
.font(.custom("Montserrat-Medium", size: 17))
|
||||
Spacer()
|
||||
Picker("Напоминание", selection: $vm._class.notification, content: {
|
||||
ForEach(MockData.notifications, id: \.self) {
|
||||
@ -160,7 +163,7 @@ struct CreateEditClassView: View {
|
||||
if !vm.isNew {
|
||||
Button {
|
||||
do {
|
||||
try delete(vm._class)
|
||||
try provider.delete(vm._class, in: provider.viewContext)
|
||||
dismiss()
|
||||
} catch {
|
||||
print(error)
|
||||
@ -170,7 +173,7 @@ struct CreateEditClassView: View {
|
||||
Spacer()
|
||||
Image(systemName: "trash")
|
||||
Text("Удалить занятие")
|
||||
.font(.system(size: 17, weight: .medium))
|
||||
.font(.custom("Montserrat-Medium", size: 17))
|
||||
Spacer()
|
||||
}
|
||||
.frame(height: 40)
|
||||
@ -235,7 +238,6 @@ struct CreateEditClassView: View {
|
||||
}
|
||||
if day > Calendar.current.startOfDay(for: Date()) {
|
||||
vm._class.day = day
|
||||
print(34)
|
||||
}
|
||||
}
|
||||
.onTapGesture {
|
||||
|
@ -18,7 +18,7 @@ struct MonthTabView: View {
|
||||
HStack (spacing: 34) {
|
||||
ForEach(MockData.daysOfWeek.indices, id: \.self) { index in
|
||||
Text(MockData.daysOfWeek[index])
|
||||
.font(.system(size: 15, weight: .semibold))
|
||||
.font(.custom("Montserrat-SemiBold", size: 15))
|
||||
.foregroundColor(MockData.daysOfWeek[index] == "Вс" ? Color(.red) : Color("customGray2"))
|
||||
.padding(.top, 13)
|
||||
.foregroundColor(.gray)
|
||||
@ -50,7 +50,6 @@ struct MonthTabView: View {
|
||||
monthSlider.removeAll()
|
||||
currentMonthIndex = 1
|
||||
updateMonthScreenViewForNewGroup()
|
||||
print(52)
|
||||
vm.isNewGroup = false
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ struct WeekTabView: View {
|
||||
weekSlider.removeAll()
|
||||
currentWeekIndex = 1
|
||||
updateWeekScreenViewForNewGroup()
|
||||
print(52)
|
||||
vm.isNewGroup = false
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ struct WeekViewForMonth: View {
|
||||
ForEach(week) { day in
|
||||
VStack {
|
||||
Text(day.date.format("dd"))
|
||||
.font(.system(size: 15, weight: .bold))
|
||||
.font(.custom("Montserrat-Medium", size: 15))
|
||||
.foregroundStyle(getForegroundColor(day: day))
|
||||
}
|
||||
.frame(width: 30, height: 30, alignment: .center)
|
||||
|
@ -18,12 +18,12 @@ struct WeekViewForWeek: View {
|
||||
ForEach(week) { day in
|
||||
VStack (spacing: 1) {
|
||||
Text(day.date.format("E"))
|
||||
.font(.system(size: 15, weight: .semibold))
|
||||
.font(.custom("Montserrat-Medium", size: 16))
|
||||
.foregroundColor(day.date.format("E") == "Вс" ? Color(.red) : isSameDate(day.date, vm.selectedDay) ? Color("customGray1") : Color("customGray3"))
|
||||
.padding(.top, 13)
|
||||
.foregroundColor(.gray)
|
||||
Text(day.date.format("dd"))
|
||||
.font(.system(size: 15, weight: .bold))
|
||||
.font(.custom("Montserrat-Medium", size: 15))
|
||||
.foregroundStyle(isSameDate(day.date, vm.selectedDay) ? .white : .black)
|
||||
.padding(.bottom, 13)
|
||||
}
|
||||
|
@ -47,7 +47,27 @@ final class ClassProvider {
|
||||
fatalError("Unable to load store. Error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func exists(_ lesson: ClassModel, in context: NSManagedObjectContext) -> ClassModel? {
|
||||
try? context.existingObject(with: lesson.objectID) as? ClassModel
|
||||
}
|
||||
|
||||
func delete(_ lesson: ClassModel, in context: NSManagedObjectContext) throws {
|
||||
if let existingClass = exists(lesson, in: context) {
|
||||
context.delete(existingClass)
|
||||
Task(priority: .background) {
|
||||
try await context.perform {
|
||||
try context.save()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func persist(in context: NSManagedObjectContext) throws {
|
||||
if context.hasChanges {
|
||||
try context.save()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,16 +160,3 @@ extension View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension CreateEditClassView {
|
||||
func delete(_ _class: ClassModel) throws {
|
||||
let context = provider.viewContext
|
||||
let existingClass = try context.existingObject(with: _class.objectID)
|
||||
context.delete(existingClass)
|
||||
Task (priority: .background) {
|
||||
try await context.perform {
|
||||
try context.save()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,13 +13,16 @@ final class EditClassViewModel: ObservableObject {
|
||||
|
||||
let isNew: Bool
|
||||
|
||||
private let provider: ClassProvider
|
||||
|
||||
private let context: NSManagedObjectContext
|
||||
|
||||
init(provider: ClassProvider, _class: ClassModel? = nil) {
|
||||
self.provider = provider
|
||||
self.context = provider.newContext
|
||||
|
||||
if let _class,
|
||||
let existingClassCopy = try? context.existingObject(with: _class.objectID) as? ClassModel {
|
||||
let existingClassCopy = provider.exists(_class, in: context) {
|
||||
self._class = existingClassCopy
|
||||
self.isNew = false
|
||||
}
|
||||
@ -30,8 +33,6 @@ final class EditClassViewModel: ObservableObject {
|
||||
}
|
||||
|
||||
func save() throws {
|
||||
if context.hasChanges {
|
||||
try context.save()
|
||||
}
|
||||
try provider.persist(in: context)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user