Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: v4 #77

Merged
merged 11 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Xcode Select Version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15'
xcode-version: '16'

- name: Setup Certificate
uses: apple-actions/import-codesign-certs@v2
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
to: HEAD

- name: Build macOS app
run: xcodebuild archive -scheme "ishare (external)" -configuration "Release" -archivePath "build/ishare.xcarchive" -destination "generic/platform=macOS,name=Any Mac" | xcbeautify
run: xcodebuild archive -scheme "ishare" -configuration "Release" -archivePath "build/ishare.xcarchive" -destination "generic/platform=macOS,name=Any Mac" "OTHER_SWIFT_FLAGS=${inherited} -D NOT_APP_STORE" | xcbeautify

- name: Commit & Push changes
uses: EndBug/add-and-commit@v9
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@
</p>
<p align="center">
<a href="https://github.com/castdrian/ishare/releases/latest/download/ishare_macOS.zip" download>
<img src="https://www.dmo-app.com/wp-content/uploads/2022/05/mac-download-button-1.png" alt="Download Latest Release" width="200">
<img src="https://i.imgur.com/EthZVfR.png" alt="Download Latest Release" width="200">
</a>
</p>

[Translate on Crowdin](https://crowdin.com/project/isharemac)

## 🚀 Features

<details markdown="block">
Expand Down
4 changes: 4 additions & 0 deletions crowdin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
files:
- source: ishare/Localizable.xcstrings
translation: ishare/Localizable.xcstrings
multilingual: 1
424 changes: 110 additions & 314 deletions ishare.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "457379c019910912d45c64f6cf194185cf499a36d1e88eb6d8948ac28538815f",
"originHash" : "0ff71dfe84467feffceb6531c60ede9b64ff3b4c3d2be319eef820d7bd3a275c",
"pins" : [
{
"identity" : "alamofire",
Expand All @@ -24,8 +24,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/sindresorhus/Defaults",
"state" : {
"revision" : "38925e3cfacf3fb89a81a35b1cd44fd5a5b7e0fa",
"version" : "8.2.0"
"revision" : "d8a954e69ff13b0f7805f3757c8f8d0c8ef5a8cb",
"version" : "9.0.0-beta.3"
}
},
{
Expand Down Expand Up @@ -69,8 +69,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/sparkle-project/Sparkle",
"state" : {
"revision" : "87e4fcbac39912f9cdb9a9acf205cad60e1ca3bc",
"version" : "2.4.2"
"revision" : "0ef1ee0220239b3776f433314515fd849025673f",
"version" : "2.6.4"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion ishare.xcodeproj/xcshareddata/xcschemes/ishare.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
LastUpgradeVersion = "1600"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>2</integer>
<integer>4</integer>
</dict>
<key>Playground (Playground) 2.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>3</integer>
<integer>5</integer>
</dict>
<key>Playground (Playground).xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>1</integer>
<integer>3</integer>
</dict>
<key>ishare (external).xcscheme_^#shared#^_</key>
<key>ishare.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
<key>ishare.xcscheme_^#shared#^_</key>
<key>sharemenuext.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
Expand Down
182 changes: 113 additions & 69 deletions ishare/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,107 +5,151 @@
// Created by Adrian Castro on 10.07.23.
//

import SwiftUI
import Defaults
import MenuBarExtraAccess
import SwiftUI

#if NOT_APP_STORE
import Sparkle
import Sparkle
#endif

@main
struct ishare: App {
@Default(.menuBarIcon) var menubarIcon
@Default(.showMainMenu) var showMainMenu
@StateObject private var appState = AppState()
@NSApplicationDelegateAdaptor private var appDelegate : AppDelegate
@NSApplicationDelegateAdaptor private var appDelegate: AppDelegate

var body: some Scene {
MenuBarExtra() {
MenuBarExtra {
MainMenuView()
}
label: {
switch menubarIcon {
case .DEFAULT: Image(nsImage: GlyphIcon)
case .APPICON: Image(nsImage: AppIcon)
case .SYSTEM: Image(systemName: "photo.on.rectangle.angled")
label: {
switch menubarIcon {
case .DEFAULT: Image(nsImage: GlyphIcon)
case .APPICON: Image(nsImage: AppIcon)
case .SYSTEM: Image(systemName: "photo.on.rectangle.angled")
}
}
}
.menuBarExtraAccess(isPresented: $showMainMenu)
.menuBarExtraAccess(isPresented: $showMainMenu)
Settings {
SettingsMenuView()
}
}
}

#if NOT_APP_STORE
class AppDelegate: NSObject, NSApplicationDelegate, SPUUpdaterDelegate {
static private(set) var shared: AppDelegate! = nil
var recordGif = false
var screenRecorder: ScreenRecorder!
var updaterController: SPUStandardUpdaterController!

func application(_ application: NSApplication, open urls: [URL]) {
if urls.count == 1 {
importIscu(urls.first!)
class AppDelegate: NSObject, NSApplicationDelegate, SPUUpdaterDelegate {
private(set) static var shared: AppDelegate! = nil
var recordGif = false
var screenRecorder: ScreenRecorder!
var updaterController: SPUStandardUpdaterController!

func application(_: NSApplication, open urls: [URL]) {
if urls.first!.isFileURL {
importIscu(urls.first!)
}

if let url = urls.first {
let path = url.host
let queryItems = URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems

if path == "upload" {
if let fileItem = queryItems?.first(where: { $0.name == "file" }) {
if let encodedFileURLString = fileItem.value, let decodedFileURLString = encodedFileURLString.removingPercentEncoding, let fileURL = URL(string: decodedFileURLString) {
print("Received file URL: \(fileURL.absoluteString)")

@Default(.uploadType) var uploadType

uploadFile(fileURL: fileURL, uploadType: uploadType) {
showToast(fileURL: fileURL) {
NSSound.beep()
}
}
}
}
}
}
}
}

func applicationDidFinishLaunching(_ notification: Notification) {
AppDelegate.shared = self

Task {
screenRecorder = ScreenRecorder()

func applicationDidFinishLaunching(_: Notification) {
AppDelegate.shared = self

Task {
screenRecorder = ScreenRecorder()
}

updaterController = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: self, userDriverDelegate: nil)
}

updaterController = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: self, userDriverDelegate: nil)
}

func stopRecording() {
Task {
await screenRecorder.stop { [self] result in
switch result {
case .success(let url):
print("Recording stopped successfully. URL: \(url)")
postRecordingTasks(url, recordGif)
case .failure(let error):
print("Error while stopping recording: \(error.localizedDescription)")

func stopRecording() {
Task {
await screenRecorder.stop { [self] result in
switch result {
case let .success(url):
print("Recording stopped successfully. URL: \(url)")
postRecordingTasks(url, recordGif)
case let .failure(error):
print("Error while stopping recording: \(error.localizedDescription)")
}
}
}
}
}
}
#else
class AppDelegate: NSObject, NSApplicationDelegate {
static private(set) var shared: AppDelegate! = nil
var recordGif = false
var screenRecorder: ScreenRecorder!

func application(_ application: NSApplication, open urls: [URL]) {
if urls.count == 1 {
importIscu(urls.first!)

class AppDelegate: NSObject, NSApplicationDelegate {
private(set) static var shared: AppDelegate! = nil
var recordGif = false
var screenRecorder: ScreenRecorder!

func application(_: NSApplication, open urls: [URL]) {
if urls.first!.isFileURL {
importIscu(urls.first!)
}

if let url = urls.first {
let path = url.host
let queryItems = URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems

if path == "upload" {
if let fileItem = queryItems?.first(where: { $0.name == "file" }) {
if let encodedFileURLString = fileItem.value, let decodedFileURLString = encodedFileURLString.removingPercentEncoding, let fileURL = URL(string: decodedFileURLString) {
print("Received file URL: \(fileURL.absoluteString)")

@Default(.uploadType) var uploadType

uploadFile(fileURL: fileURL, uploadType: uploadType) {
showToast(fileURL: fileURL) {
NSSound.beep()
}
}
}
}
}
}
}
}

func applicationDidFinishLaunching(_ notification: Notification) {
AppDelegate.shared = self

Task {
screenRecorder = ScreenRecorder()

func applicationDidFinishLaunching(_: Notification) {
AppDelegate.shared = self

Task {
screenRecorder = ScreenRecorder()
}
}
}

func stopRecording() {
Task {
await screenRecorder.stop { [self] result in
switch result {
case .success(let url):
print("Recording stopped successfully. URL: \(url)")
postRecordingTasks(url, recordGif)
case .failure(let error):
print("Error while stopping recording: \(error.localizedDescription)")

func stopRecording() {
Task {
await screenRecorder.stop { [self] result in
switch result {
case let .success(url):
print("Recording stopped successfully. URL: \(url)")
postRecordingTasks(url, recordGif)
case let .failure(error):
print("Error while stopping recording: \(error.localizedDescription)")
}
}
}
}
}
}
#endif
Loading