From 2df0ce76040ddd4b2454eded220670b3a495b4f4 Mon Sep 17 00:00:00 2001 From: kingbri Date: Thu, 21 Jul 2022 17:53:16 -0400 Subject: [PATCH] Ferrite: Fix toast UI Refactor the GroupBox style and make error fonts smaller to not impede the user's experience. Signed-off-by: kingbri --- Ferrite.xcodeproj/project.pbxproj | 4 ++++ Ferrite/Views/CommonViews/GroupBoxStyle.swift | 20 +++++++++++++++++++ Ferrite/Views/MainView.swift | 10 +++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 Ferrite/Views/CommonViews/GroupBoxStyle.swift diff --git a/Ferrite.xcodeproj/project.pbxproj b/Ferrite.xcodeproj/project.pbxproj index a8e9e80..7985319 100644 --- a/Ferrite.xcodeproj/project.pbxproj +++ b/Ferrite.xcodeproj/project.pbxproj @@ -32,6 +32,7 @@ 0CA148EB288903F000DE2211 /* SearchResultsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148D3288903F000DE2211 /* SearchResultsView.swift */; }; 0CA148EC288903F000DE2211 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148D4288903F000DE2211 /* ContentView.swift */; }; 0CAF1C7B286F5C8600296F86 /* SwiftSoup in Frameworks */ = {isa = PBXBuildFile; productRef = 0CAF1C7A286F5C8600296F86 /* SwiftSoup */; }; + 0CFEFCFD288A006200B3F490 /* GroupBoxStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CFEFCFC288A006200B3F490 /* GroupBoxStyle.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -57,6 +58,7 @@ 0CA148D3288903F000DE2211 /* SearchResultsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchResultsView.swift; sourceTree = ""; }; 0CA148D4288903F000DE2211 /* ContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 0CAF1C68286F5C0E00296F86 /* Ferrite.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Ferrite.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 0CFEFCFC288A006200B3F490 /* GroupBoxStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupBoxStyle.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -92,6 +94,7 @@ isa = PBXGroup; children = ( 0CA148C1288903F000DE2211 /* NavView.swift */, + 0CFEFCFC288A006200B3F490 /* GroupBoxStyle.swift */, ); path = CommonViews; sourceTree = ""; @@ -265,6 +268,7 @@ 0CA148D8288903F000DE2211 /* MagnetChoiceView.swift in Sources */, 0CA148E3288903F000DE2211 /* Task.swift in Sources */, 0CA148E7288903F000DE2211 /* ToastViewModel.swift in Sources */, + 0CFEFCFD288A006200B3F490 /* GroupBoxStyle.swift in Sources */, 0CA148E6288903F000DE2211 /* WebView.swift in Sources */, 0CA148E2288903F000DE2211 /* Data.swift in Sources */, 0CA148DE288903F000DE2211 /* RealDebridModels.swift in Sources */, diff --git a/Ferrite/Views/CommonViews/GroupBoxStyle.swift b/Ferrite/Views/CommonViews/GroupBoxStyle.swift new file mode 100644 index 0000000..5bfc686 --- /dev/null +++ b/Ferrite/Views/CommonViews/GroupBoxStyle.swift @@ -0,0 +1,20 @@ +// +// GroupBoxStyle.swift +// Ferrite +// +// Created by Brian Dashore on 7/21/22. +// + +import SwiftUI + +struct ErrorGroupBoxStyle: GroupBoxStyle { + func makeBody(configuration: Configuration) -> some View { + VStack { + configuration.label + configuration.content + } + .padding(10) + .background(Color(uiColor: .secondarySystemGroupedBackground)) + .clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous)) + } +} diff --git a/Ferrite/Views/MainView.swift b/Ferrite/Views/MainView.swift index c5637ab..4395214 100644 --- a/Ferrite/Views/MainView.swift +++ b/Ferrite/Views/MainView.swift @@ -42,11 +42,15 @@ struct MainView: View { Text("Error: \(toastModel.toastDescription ?? "This shouldn't be showing up... Contact the dev!")") } } + .groupBoxStyle(ErrorGroupBoxStyle()) + + Rectangle() + .foregroundColor(.clear) + .frame(height: 60) } } - .transition(AnyTransition.move(edge: .bottom)) - .animation(.easeInOut(duration: 0.3), value: true) - .padding() + .font(.caption) + .animation(.easeInOut(duration: 0.3), value: toastModel.showToast) } } }