-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
188 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+3.09 KB
(110%)
...oj/project.xcworkspace/xcuserdata/mattrighetti.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
Oops, something went wrong.