Skip to content

Commit

Permalink
PreviewProvider -> #Preview
Browse files Browse the repository at this point in the history
  • Loading branch information
Ceylo committed Nov 3, 2024
1 parent 2286b88 commit f0cf1ef
Show file tree
Hide file tree
Showing 17 changed files with 62 additions and 99 deletions.
6 changes: 2 additions & 4 deletions FAKit/Sources/FAKit/FALoginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ public struct FALoginView: View {
}
}

struct FALoginView_Previews: PreviewProvider {
static var previews: some View {
FALoginView(session: .constant(nil))
}
#Preview {
FALoginView(session: .constant(nil))
}
10 changes: 4 additions & 6 deletions FAKit/Sources/FAKit/WebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,8 @@ struct WebView: UIViewRepresentable {
}
}

struct WebView_Previews: PreviewProvider {
static var previews: some View {
WebView(initialUrl: URL(string: "https://apple.com/")!,
cookies: .constant([]),
clearCookies: false)
}
#Preview {
WebView(initialUrl: URL(string: "https://apple.com/")!,
cookies: .constant([]),
clearCookies: false)
}
6 changes: 2 additions & 4 deletions FurAffinity/Helper Views/ActionControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ struct ActionControl: View {
}
}

struct ActionControl_Previews: PreviewProvider {
static var previews: some View {
ActionControl()
}
#Preview {
ActionControl()
}
8 changes: 3 additions & 5 deletions FurAffinity/Helper Views/DateTimeButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ struct DateTimeButton: View {
}
}

struct DateTimeButton_Previews: PreviewProvider {
static var previews: some View {
DateTimeButton(datetime: "Apr 7th, 2022, 11:58 AM",
naturalDatetime: "8 months ago")
}
#Preview {
DateTimeButton(datetime: "Apr 7th, 2022, 11:58 AM",
naturalDatetime: "8 months ago")
}
18 changes: 8 additions & 10 deletions FurAffinity/Helper Views/HTMLView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ struct HTMLView: View {



struct TextView_Previews: PreviewProvider {
static var html: String {
#Preview {
var html: String {
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html lang=\"en\" class=\"no-js\" xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n<meta charset=\"utf-8\" />\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n<link type=\"text/css\" rel=\"stylesheet\" href=\"/themes/beta/css/ui_theme_dark.css\" /></head>\n<body data-static-path=\"/themes/beta\">"
+
"<code class=\"bbcode bbcode_center\"><strong class=\"bbcode bbcode_b\"> Happy New Year, guys! <br> Let the New Year bring happiness and joy to every home, because each of you deserves all the best!<br> Love you all!!! </strong></code>\n<br> \n<br> \n<br> \n<br> \n<br> \n<br> Rudy © \n<a href=\"/user/ruddi\" class=\"iconusername\"><img src=\"//a.furaffinity.net/20211231/ruddi.gif\" align=\"middle\" title=\"ruddi\" alt=\"ruddi\"></a>\n<br> Rigel Peyton © \n<a href=\"/user/lil-maj\" class=\"iconusername\"><img src=\"//a.furaffinity.net/20211231/lil-maj.gif\" align=\"middle\" title=\"lil-Maj\" alt=\"lil-Maj\"></a> \n<br> Annet © \n<a href=\"/user/annetpeas\" class=\"iconusername\"><img src=\"//a.furaffinity.net/20211231/annetpeas.gif\" align=\"middle\" title=\"annetpeas\" alt=\"annetpeas\"></a> \n<br> Seth © \n<a href=\"/user/longdanger\" class=\"iconusername\"><img src=\"https://a.furaffinity.net/20211231/longdanger.gif\" align=\"middle\" title=\"longdanger\" alt=\"longdanger\"></a>\n<br> \n<br> and Bulka © irl my pet cat \n<br> \n<br> \n<br> *******************************\n<br> * \n<a class=\"auto_link named_url\" href=\"http://ko-fi.com/J3J16KSH\">Feed me with coffee?</a>\n<br> * \n<a class=\"auto_link named_url\" href=\"https://www.furaffinity.net/gallery/annetpeas/\">My Gallery</a>\n<br> * \n<a class=\"auto_link named_url\" href=\"https://twitter.com/AnnetPeas_Art\">Twitter</a>"
+
"</body></html>"
}

static var attributedString: AttributedString {
var attributedString: AttributedString {
let data = html
.replacingOccurrences(of: "href=\"/", with: "href=\"https://www.furaffinity.net/")
.replacingOccurrences(of: "src=\"//", with: "src=\"https://")
Expand All @@ -91,12 +91,10 @@ struct TextView_Previews: PreviewProvider {
return AttributedString(nsattrstr)
}

static var previews: some View {
ScrollView {
HTMLView(text: attributedString)
.border(.yellow)
}
.border(.blue)
.preferredColorScheme(.dark)
ScrollView {
HTMLView(text: attributedString)
.border(.yellow)
}
.border(.blue)
.preferredColorScheme(.dark)
}
6 changes: 2 additions & 4 deletions FurAffinity/Helper Views/LoadingFailedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ struct LoadingFailedView: View {
}
}

struct LoadingFailedView_Previews: PreviewProvider {
static var previews: some View {
LoadingFailedView(url: FAURLs.homeUrl)
}
#Preview {
LoadingFailedView(url: FAURLs.homeUrl)
}
11 changes: 4 additions & 7 deletions FurAffinity/Helper Views/NotificationOverlay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,8 @@ struct NotificationOverlay: View {
}
}

struct NotificationOverlay_Previews: PreviewProvider {
static var previews: some View {
NotificationOverlay(itemCount: .constant(12))
.padding()
.background(.yellow)
.previewLayout(.sizeThatFits)
}
#Preview(traits: .sizeThatFitsLayout) {
NotificationOverlay(itemCount: .constant(12))
.padding()
.background(.yellow)
}
12 changes: 5 additions & 7 deletions FurAffinity/Helper Views/SaveButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ struct SaveButton: View {
}
}

struct SaveButton_Previews: PreviewProvider {
static var previews: some View {
HStack {
ForEach(ActionState.allCases) { state in
SaveButton(state: state) {
}
.frame(width: 60, height: 60)
#Preview {
HStack {
ForEach(ActionState.allCases) { state in
SaveButton(state: state) {
}
.frame(width: 60, height: 60)
}
}
}
10 changes: 3 additions & 7 deletions FurAffinity/Helper Views/TitledHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ extension TitledHeaderView: SubmissionHeaderView {
}
}

struct SubmissionTitledHeaderView_Previews: PreviewProvider {
static var previews: some View {
TitledHeaderView(title: "Great Content")
.previewLayout(.sizeThatFits)
.preferredColorScheme(.dark)

}
#Preview(traits: .sizeThatFitsLayout) {
TitledHeaderView(title: "Great Content")
.preferredColorScheme(.dark)
}
8 changes: 3 additions & 5 deletions FurAffinity/LoggedInView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ struct LoggedInView: View {
}
}

struct LoggedInView_Previews: PreviewProvider {
static var previews: some View {
LoggedInView()
.environmentObject(Model.demo)
}
#Preview {
LoggedInView()
.environmentObject(Model.demo)
}
8 changes: 3 additions & 5 deletions FurAffinity/Notifications/CommentNotificationItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ struct CommentNotificationItemView: View {
}
}

struct SubmissionCommentNotificationItemView_Previews: PreviewProvider {
static var notification: FANotificationPreview {
#Preview {
var notification: FANotificationPreview {
.init(
id: 172177443,
author: "someuser",
Expand All @@ -54,7 +54,5 @@ struct SubmissionCommentNotificationItemView_Previews: PreviewProvider {
)
}

static var previews: some View {
CommentNotificationItemView(notification: notification)
}
CommentNotificationItemView(notification: notification)
}
8 changes: 3 additions & 5 deletions FurAffinity/Notifications/JournalNotificationItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ struct JournalNotificationItemView: View {
}
}

struct JournalNotificationItemView_Previews: PreviewProvider {
static var journal: FANotificationPreview {
#Preview {
var journal: FANotificationPreview {
let previews = OfflineFASession.default.notificationPreviews
return previews.journals.first!
}

static var previews: some View {
JournalNotificationItemView(journal: journal)
}
JournalNotificationItemView(journal: journal)
}
8 changes: 3 additions & 5 deletions FurAffinity/Notifications/ShoutNotificationItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ struct ShoutNotificationItemView: View {
}
}

struct ShoutNotificationItemView_Previews: PreviewProvider {
static var shout: FANotificationPreview {
#Preview {
var shout: FANotificationPreview {
let previews = OfflineFASession.default.notificationPreviews
return previews.shouts.first!
}

static var previews: some View {
ShoutNotificationItemView(shout: shout)
}
ShoutNotificationItemView(shout: shout)
}
8 changes: 3 additions & 5 deletions FurAffinity/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ struct SettingsView: View {
}
}

struct SettingsView_Previews: PreviewProvider {
static var previews: some View {
SettingsView()
.environmentObject(Model.demo)
}
#Preview {
SettingsView()
.environmentObject(Model.demo)
}
12 changes: 5 additions & 7 deletions FurAffinity/SubmissionsFeed/SubmissionsFeedActionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ struct SubmissionsFeedActionView: View {
}
}

struct SubmissionsFeedActionView_Previews: PreviewProvider {
static var previews: some View {
SubmissionsFeedActionView()
.padding()
.background(.yellow)
.environmentObject(Model.demo)
}
#Preview {
SubmissionsFeedActionView()
.padding()
.background(.yellow)
.environmentObject(Model.demo)
}
8 changes: 3 additions & 5 deletions FurAffinity/User/CurrentUserView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ struct CurrentUserView: View {
}
}

struct CurentUserView_Previews: PreviewProvider {
static var previews: some View {
CurrentUserView()
.environmentObject(Model.demo)
}
#Preview {
CurrentUserView()
.environmentObject(Model.demo)
}
14 changes: 6 additions & 8 deletions FurAffinity/User/RemoteUserGalleryLikeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ struct RemoteUserGalleryLikeView: View {
}
}

struct RemoteUserGalleryLikeView_Previews: PreviewProvider {
static var previews: some View {
RemoteUserGalleryLikeView(
galleryType: .gallery,
url: URL(string: "https://www.furaffinity.net/gallery/tiaamaito/")!
)
.environmentObject(Model.demo)
}
#Preview {
RemoteUserGalleryLikeView(
galleryType: .gallery,
url: URL(string: "https://www.furaffinity.net/gallery/tiaamaito/")!
)
.environmentObject(Model.demo)
}

0 comments on commit f0cf1ef

Please sign in to comment.