Skip to content

Commit

Permalink
Merge branch 'fix/misc-fixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrighetti committed Nov 5, 2023
2 parents daedb0f + 4afd2db commit a35843a
Show file tree
Hide file tree
Showing 12 changed files with 188 additions and 73 deletions.
28 changes: 20 additions & 8 deletions HNReader.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
5F109D602AF704F700AE6AF3 /* IBMPlexSerif-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 5F109D5C2AF704F700AE6AF3 /* IBMPlexSerif-Bold.ttf */; };
5F109D612AF704F700AE6AF3 /* IBMPlexSerif-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 5F109D5D2AF704F700AE6AF3 /* IBMPlexSerif-Regular.ttf */; };
5F109D622AF704F700AE6AF3 /* IBMPlexSerif-SemiBold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 5F109D5E2AF704F700AE6AF3 /* IBMPlexSerif-SemiBold.ttf */; };
5FCE20A72AF7B25A00BF4097 /* InfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FCE20A62AF7B25A00BF4097 /* InfoView.swift */; };
5FCE20A92AF7B47B00BF4097 /* BgButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FCE20A82AF7B47B00BF4097 /* BgButton.swift */; };
5FCE20AB2AF7B8EE00BF4097 /* +View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FCE20AA2AF7B8EE00BF4097 /* +View.swift */; };
C93F99B6267554F00046F870 /* ItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C93F99B5267554F00046F870 /* ItemCell.swift */; };
C93F99B8267557FC0046F870 /* ItemList.swift in Sources */ = {isa = PBXBuildFile; fileRef = C93F99B7267557FC0046F870 /* ItemList.swift */; };
C93F99BA267580CE0046F870 /* HTMLText.swift in Sources */ = {isa = PBXBuildFile; fileRef = C93F99B9267580CE0046F870 /* HTMLText.swift */; };
Expand Down Expand Up @@ -59,6 +62,9 @@
5F109D5C2AF704F700AE6AF3 /* IBMPlexSerif-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "IBMPlexSerif-Bold.ttf"; sourceTree = "<group>"; };
5F109D5D2AF704F700AE6AF3 /* IBMPlexSerif-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "IBMPlexSerif-Regular.ttf"; sourceTree = "<group>"; };
5F109D5E2AF704F700AE6AF3 /* IBMPlexSerif-SemiBold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "IBMPlexSerif-SemiBold.ttf"; sourceTree = "<group>"; };
5FCE20A62AF7B25A00BF4097 /* InfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoView.swift; sourceTree = "<group>"; };
5FCE20A82AF7B47B00BF4097 /* BgButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BgButton.swift; sourceTree = "<group>"; };
5FCE20AA2AF7B8EE00BF4097 /* +View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "+View.swift"; sourceTree = "<group>"; };
C93F99B5267554F00046F870 /* ItemCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemCell.swift; sourceTree = "<group>"; };
C93F99B7267557FC0046F870 /* ItemList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemList.swift; sourceTree = "<group>"; };
C93F99B9267580CE0046F870 /* HTMLText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTMLText.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -101,6 +107,7 @@
isa = PBXGroup;
children = (
3307159309D438EFAA1259C7 /* +Date.swift */,
5FCE20AA2AF7B8EE00BF4097 /* +View.swift */,
);
path = Utils;
sourceTree = "<group>";
Expand Down Expand Up @@ -145,6 +152,7 @@
isa = PBXGroup;
children = (
C93F99B9267580CE0046F870 /* HTMLText.swift */,
5FCE20A82AF7B47B00BF4097 /* BgButton.swift */,
);
path = Components;
sourceTree = "<group>";
Expand Down Expand Up @@ -213,6 +221,7 @@
C93F99B7267557FC0046F870 /* ItemList.swift */,
C9926691267588B80035A88F /* Components */,
5F109D582AF6F50D00AE6AF3 /* ConditionalRedactedModifier.swift */,
5FCE20A62AF7B25A00BF4097 /* InfoView.swift */,
);
path = View;
sourceTree = "<group>";
Expand Down Expand Up @@ -358,6 +367,8 @@
C9D0938026741BBF002CC786 /* Persistence.swift in Sources */,
C9D0937926741BBE002CC786 /* HomeView.swift in Sources */,
C93F99B6267554F00046F870 /* ItemCell.swift in Sources */,
5FCE20A92AF7B47B00BF4097 /* BgButton.swift in Sources */,
5FCE20A72AF7B25A00BF4097 /* InfoView.swift in Sources */,
5F109D592AF6F50D00AE6AF3 /* ConditionalRedactedModifier.swift in Sources */,
C93F99B8267557FC0046F870 /* ItemList.swift in Sources */,
C9E9BCFD2674C80E001B4E19 /* AppState.swift in Sources */,
Expand All @@ -369,6 +380,7 @@
330713D3016ED410AFD53FDF /* ItemListViewModel.swift in Sources */,
330711A9216E762026AF98A0 /* +Date.swift in Sources */,
33071F1C64D4742E1F947FAA /* ItemDownloader.swift in Sources */,
5FCE20AB2AF7B8EE00BF4097 /* +View.swift in Sources */,
3307147AB95F03650FC40B97 /* ItemCache.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -527,21 +539,21 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 3;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"HNReader/Preview Content\"";
DEVELOPMENT_TEAM = H89RFW5UZ6;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = HNReader/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = HNReader;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.news";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.2;
MARKETING_VERSION = 1.3;
PRODUCT_BUNDLE_IDENTIFIER = com.mattrighetti.HNReader;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -560,21 +572,21 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 3;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"HNReader/Preview Content\"";
DEVELOPMENT_TEAM = H89RFW5UZ6;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = HNReader/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = HNReader;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.news";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.2;
MARKETING_VERSION = 1.3;
PRODUCT_BUNDLE_IDENTIFIER = com.mattrighetti.HNReader;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -597,7 +609,7 @@
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 14.0;
PRODUCT_BUNDLE_IDENTIFIER = com.mattrighetti.HNReaderTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -620,7 +632,7 @@
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 14.0;
PRODUCT_BUNDLE_IDENTIFIER = com.mattrighetti.HNReaderTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions HNReader/HNReaderApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ struct HNReaderApp: App {
Text("Light").tag(ColorScheme.light)
}
.pickerStyle(SegmentedPickerStyle())
.frame(maxWidth: 100)
.frame(maxWidth: 200)
}
}
.frame(minHeight: 100)
.frame(minWidth: 100)
.frame(minWidth: 300)
.preferredColorScheme(displayMode)
}
}
Expand Down
16 changes: 8 additions & 8 deletions HNReader/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIAppFonts</key>
<array>
<string>IBMPlexSerif-Bold.ttf</string>
<string>IBMPlexSerif-SemiBold.ttf</string>
<string>IBMPlexSerif-Regular.ttf</string>
<string>IBMPlexSerif-Light.ttf</string>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
Expand All @@ -22,12 +15,19 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.2</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.news</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>UIAppFonts</key>
<array>
<string>IBMPlexSerif-Bold.ttf</string>
<string>IBMPlexSerif-SemiBold.ttf</string>
<string>IBMPlexSerif-Regular.ttf</string>
<string>IBMPlexSerif-Light.ttf</string>
</array>
</dict>
</plist>
20 changes: 20 additions & 0 deletions HNReader/Utils/+View.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// +View.swift
// HNReader
//
// Created by Mattia Righetti on 05/11/23.
//

import SwiftUI

extension View {
@discardableResult
func openInWindow(title: String, sender: Any?) -> NSWindow {
let controller = NSHostingController(rootView: self)
let win = NSWindow(contentViewController: controller)
win.contentViewController = controller
win.title = title
win.makeKeyAndOrderFront(sender)
return win
}
}
47 changes: 47 additions & 0 deletions HNReader/View/Components/BgButton.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// BgButton.swift
// HNReader
//
// Created by Mattia Righetti on 05/11/23.
//

import SwiftUI

struct BgButton: View {
var text: String? = nil
var icon: String
var disabled: Bool = false
var minSize: CGSize
var onHover: ((Bool) -> Void)? = nil
var action: (() -> ())? = nil

var body: some View {
ZStack {
RoundedRectangle(cornerRadius: 15)
.foregroundStyle(Color.gray.opacity(0.1))
.frame(width: minSize.width, height: minSize.height)

Label(title: {
if text != nil {
Text(text!)
.font(.custom("IBMPlexSerif-Regular", size: 13))
}
}, icon: {
Image(systemName: icon)
})
.foregroundStyle(disabled ? .tertiary : .primary)
.padding()
}
.frame(width: minSize.width, height: minSize.height)
.onHover {
onHover?($0)
}
.onTapGesture {
action?()
}
}
}

#Preview {
BgButton(text: "Rate app", icon: "star", minSize: CGSize(width: 150, height: 50)).padding()
}
12 changes: 5 additions & 7 deletions HNReader/View/Components/HTMLText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ struct HTMLText: NSViewRepresentable {
func updateNSView(_ nsView: NSViewType, context: Context) {}
}

struct HTMLText_Previews: PreviewProvider {
static var previews: some View {
HTMLText(text: """
string &lt;h1&gt;Krupal testing &lt;span style="font-weight:
bold;"&gt;Customer WYWO&lt;/span&gt;&lt;/h1&gt;
""")
}
#Preview {
HTMLText(text: """
string &lt;h1&gt;Krupal testing &lt;span style="font-weight:
bold;"&gt;Customer WYWO&lt;/span&gt;&lt;/h1&gt;
""")
}
5 changes: 3 additions & 2 deletions HNReader/View/ConditionalRedactedModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ extension View {

#Preview {
VStack {
Text("Some Text").redactIfNull(Optional<String>.none)
Text("Some Text")
.redactIfNull(Optional<String>.none)
}
.frame(width: 500, height: 500)
.frame(width: 200, height: 100)
}
6 changes: 2 additions & 4 deletions HNReader/View/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ struct Sidebar: View {
}
}

struct HomeView_Previews: PreviewProvider {
static var previews: some View {
HomeView()
}
#Preview {
HomeView()
}
64 changes: 64 additions & 0 deletions HNReader/View/InfoView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// InfoView.swift
// HNReader
//
// Created by Mattia Righetti on 05/11/23.
//

import AppKit
import StoreKit
import SwiftUI

struct InfoView: View {
var version: String {
let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as! String
/// Build version of the app, i.e. `64`
let appBundleVersion: String = Bundle.main.infoDictionary?["CFBundleVersion"] as! String

return "\(version) (\(appBundleVersion))"
}

var body: some View {
VStack {
Text("HNReader v\(version)")
.font(.custom("IBMPlexSerif-SemiBold", size: 15))

Text("This project is open source, if you like it you can star it on GitHub.")
.lineLimit(4)
.font(.custom("IBMPlexSerif-Regular", size: 13))
.foregroundStyle(.secondary)
.multilineTextAlignment(.center)
.padding(.vertical)

BgButton(text: "Rate HNReader", icon: "star", minSize: CGSize(width: 250, height: 50), onHover: { h in
DispatchQueue.main.async {
if (h) {
NSCursor.pointingHand.push()
} else {
NSCursor.pop()
}
}
}, action: {
NSWorkspace.shared.open(URL(string: "https://apps.apple.com/it/app/id1572480416?action=write-review")!)
})

BgButton(text: "Open on GitHub", icon: "arrow.up.right", minSize: CGSize(width: 250, height: 50), onHover: { h in
DispatchQueue.main.async {
if (h) {
NSCursor.pointingHand.push()
} else {
NSCursor.pop()
}
}
}, action: {
NSWorkspace.shared.open(URL(string: "https://github.com/mattrighetti/HNReaderApp.git")!)
})
}
.padding()
.frame(width: 300)
}
}

#Preview {
InfoView()
}
Loading

0 comments on commit a35843a

Please sign in to comment.