Skip to content

Commit

Permalink
Merge pull request #10 from SNQ-2001/develop
Browse files Browse the repository at this point in the history
1.1.1
  • Loading branch information
SNQ-2001 authored Jan 2, 2023
2 parents 3a0c6a0 + 343b946 commit 590b7d3
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 36 deletions.
24 changes: 12 additions & 12 deletions GitHubContributionsMenuBar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
1C6694B82822EC8F00ABFED2 /* Contribution.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C6694B72822EC8F00ABFED2 /* Contribution.swift */; };
1C6694BA2822ECA400ABFED2 /* GitHub.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C6694B92822ECA400ABFED2 /* GitHub.swift */; };
1C6694BD2822ECC500ABFED2 /* SwiftSoup in Frameworks */ = {isa = PBXBuildFile; productRef = 1C6694BC2822ECC500ABFED2 /* SwiftSoup */; };
1C6694C02822ECE100ABFED2 /* SkeletonUI in Frameworks */ = {isa = PBXBuildFile; productRef = 1C6694BF2822ECE100ABFED2 /* SkeletonUI */; };
1C6694C22822EDC300ABFED2 /* Network+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C6694C12822EDC300ABFED2 /* Network+.swift */; };
1C921BF22909399300BA091E /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 1C921BF12909399300BA091E /* README.md */; };
1CA831B9290950D900FC6AB4 /* icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 1CA831B8290950D900FC6AB4 /* icon.icns */; };
1CA8E632295DC92600F3D623 /* SkeletonUI in Frameworks */ = {isa = PBXBuildFile; productRef = 1CA8E631295DC92600F3D623 /* SkeletonUI */; };
1CAFD6862823D81100C9A576 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAFD6852823D81100C9A576 /* SettingsView.swift */; };
1CAFD68B282412F500C9A576 /* SettingsLabelStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAFD68A282412F400C9A576 /* SettingsLabelStyle.swift */; };
1CAFD68F282417F000C9A576 /* UserName.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAFD68E282417F000C9A576 /* UserName.swift */; };
Expand Down Expand Up @@ -69,7 +69,7 @@
buildActionMask = 2147483647;
files = (
1C6694BD2822ECC500ABFED2 /* SwiftSoup in Frameworks */,
1C6694C02822ECE100ABFED2 /* SkeletonUI in Frameworks */,
1CA8E632295DC92600F3D623 /* SkeletonUI in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -215,7 +215,7 @@
name = GitHubContributionsMenuBar;
packageProductDependencies = (
1C6694BC2822ECC500ABFED2 /* SwiftSoup */,
1C6694BF2822ECE100ABFED2 /* SkeletonUI */,
1CA8E631295DC92600F3D623 /* SkeletonUI */,
);
productName = GitHubContributionsMenuBar;
productReference = 1C66948E2822EA3800ABFED2 /* Contributions.app */;
Expand Down Expand Up @@ -247,7 +247,7 @@
mainGroup = 1C6694852822EA3800ABFED2;
packageReferences = (
1C6694BB2822ECC500ABFED2 /* XCRemoteSwiftPackageReference "SwiftSoup" */,
1C6694BE2822ECE100ABFED2 /* XCRemoteSwiftPackageReference "SkeletonUI" */,
1CA8E630295DC92600F3D623 /* XCRemoteSwiftPackageReference "SkeletonUI" */,
);
productRefGroup = 1C66948F2822EA3800ABFED2 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -290,7 +290,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export PATH=/opt/homebrew/bin:$PATH\n\nif which mint >/dev/null; then\n # SwiftGen\n xcrun --sdk macosx mint run swiftgen\n # SwiftLint\n xcrun --sdk macosx mint run swiftlint\n # SwiftFormat\n xcrun --sdk macosx mint run swiftformat .\n # LicensePlist\n xcrun --sdk macosx mint run mono0926/LicensePlist --output-path $PROJECT_NAME/Resource/Settings.bundle\nelse \n echo 'warning: mint not installed.'\nfi\n";
shellScript = "export PATH=/opt/homebrew/bin:$PATH\n\nif which mint >/dev/null; then\n # SwiftGen\n xcrun --sdk macosx mint run swiftgen\n # SwiftLint\n xcrun --sdk macosx mint run swiftlint\n # SwiftFormat\n xcrun --sdk macosx mint run swiftformat GitHubContributionsMenuBar\n # LicensePlist\n xcrun --sdk macosx mint run mono0926/LicensePlist --output-path $PROJECT_NAME/Resource/Settings.bundle\nelse \n echo 'warning: mint not installed.'\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down Expand Up @@ -448,7 +448,7 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 110;
CURRENT_PROJECT_VERSION = 111;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"GitHubContributionsMenuBar/Preview Content\"";
DEVELOPMENT_TEAM = 69BMRJXU5B;
Expand All @@ -465,7 +465,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.1.0;
MARKETING_VERSION = 1.1.1;
PRODUCT_BUNDLE_IDENTIFIER = com.GitHubContributionsMenuBar;
PRODUCT_NAME = Contributions;
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -483,7 +483,7 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 110;
CURRENT_PROJECT_VERSION = 111;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"GitHubContributionsMenuBar/Preview Content\"";
DEVELOPMENT_TEAM = 69BMRJXU5B;
Expand All @@ -500,7 +500,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 1.1.0;
MARKETING_VERSION = 1.1.1;
PRODUCT_BUNDLE_IDENTIFIER = com.GitHubContributionsMenuBar;
PRODUCT_NAME = Contributions;
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -540,7 +540,7 @@
minimumVersion = 2.0.0;
};
};
1C6694BE2822ECE100ABFED2 /* XCRemoteSwiftPackageReference "SkeletonUI" */ = {
1CA8E630295DC92600F3D623 /* XCRemoteSwiftPackageReference "SkeletonUI" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/CSolanaM/SkeletonUI";
requirement = {
Expand All @@ -556,9 +556,9 @@
package = 1C6694BB2822ECC500ABFED2 /* XCRemoteSwiftPackageReference "SwiftSoup" */;
productName = SwiftSoup;
};
1C6694BF2822ECE100ABFED2 /* SkeletonUI */ = {
1CA8E631295DC92600F3D623 /* SkeletonUI */ = {
isa = XCSwiftPackageProductDependency;
package = 1C6694BE2822ECE100ABFED2 /* XCRemoteSwiftPackageReference "SkeletonUI" */;
package = 1CA8E630295DC92600F3D623 /* XCRemoteSwiftPackageReference "SkeletonUI" */;
productName = SkeletonUI;
};
/* End XCSwiftPackageProductDependency section */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SwiftUI

@main
struct GitHubContributionsMenuBarApp: App {
@ObservedObject var viewModel = ContributionsViewModel()
@StateObject var viewModel = ContributionsViewModel()
var body: some Scene {
MenuBarExtra {
ContentView(viewModel: viewModel)
Expand Down
4 changes: 2 additions & 2 deletions GitHubContributionsMenuBar/Network/GitHub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public enum GitHub {
return dateFormatter
}()

// MARK: - Public Methods
// MARK: - internal Methods

public static func getContributions(for username: String, queue: DispatchQueue) -> Future<[Contribution], Error> {
static func getContributions(for username: String, queue: DispatchQueue) -> Future<[Contribution], Error> {
Future { promise in
queue.async {
do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public struct ContributionsView: View {
hover1 = hovering
}
.onTapGesture {
NSApp.terminate(self)
NSApplication.shared.terminate(nil)
}
.padding(.trailing, 3)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Created by 宮本大新 on 2022/05/05.
//

import SkeletonUI
import SwiftUI

struct SettingsView: View {
Expand Down
3 changes: 0 additions & 3 deletions GitHubContributionsMenuBar/View/Settings/Thema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ struct Thema: View {
.tag(3)
}
.labelsHidden()
.onChange(of: viewModel.thema) { _ in
viewModel.setThema()
}
}
}
}
3 changes: 0 additions & 3 deletions GitHubContributionsMenuBar/View/Settings/UserName.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ struct UserName: View {
.background(focusState ? .quaternary : .tertiary)
.overlay(RoundedRectangle(cornerRadius: 6).stroke(Color.gray, lineWidth: 0.5).cornerRadius(6))
.cornerRadius(6)
.onChange(of: viewModel.username) { _ in
viewModel.setUsename()
}
}
}
}
26 changes: 14 additions & 12 deletions GitHubContributionsMenuBar/ViewModel/ContributionsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,24 @@ final class ContributionsViewModel: ObservableObject {
}

@Published var contributions: Contributions = .init()
@Published var username: String = ""
@Published var thema: Int = 0
@Published var viewMode: Bool = false

@AppStorage("username") var username: String = ""
@AppStorage("thema") var thema: Int = 0

private let queue = DispatchQueue(label: "com.andergoig.GitHubContributions.network")

private var cancellable = Set<AnyCancellable>()

init() {
NotificationCenter.default.publisher(for: NSWindow.didBecomeKeyNotification)
.sink { [weak self] _ in
guard let self else { return }
self.updateContributions()
}
.store(in: &cancellable)
}

func getContributions() {
guard contributions.levels.isEmpty else { return }
GitHub.getContributions(for: username, queue: queue)
Expand All @@ -33,21 +45,11 @@ final class ContributionsViewModel: ObservableObject {

func updateContributions() {
contributions = .init()
username = UserDefaults.standard.string(forKey: "username") ?? ""
thema = UserDefaults.standard.integer(forKey: "thema")
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
self.getContributions()
}
}

func setUsename() {
UserDefaults.standard.set(username, forKey: "username")
}

func setThema() {
UserDefaults.standard.set(thema, forKey: "thema")
}

private static func mapContributions(_ contributions: [GitHub.Contribution]) -> Contributions {
guard let lastDate = contributions.last?.date else { return .init() }
let tilesCount = 7 * 20 - (7 - Calendar.current.component(.weekday, from: lastDate))
Expand Down
2 changes: 1 addition & 1 deletion Mintfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SwiftGen/[email protected]
mono0926/[email protected]
SwiftGen/[email protected]
realm/[email protected]
nicklockwood/[email protected]

0 comments on commit 590b7d3

Please sign in to comment.