Skip to content

Commit 30ae5b6

Browse files
committed
Full streak view
1 parent 55f4b6d commit 30ae5b6

File tree

5 files changed

+26
-19
lines changed

5 files changed

+26
-19
lines changed

streak-bar/streak-bar.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@
367367
CODE_SIGN_ENTITLEMENTS = "streak-bar/streak_bar.entitlements";
368368
CODE_SIGN_STYLE = Automatic;
369369
COMBINE_HIDPI_IMAGES = YES;
370-
CURRENT_PROJECT_VERSION = 2;
370+
CURRENT_PROJECT_VERSION = 5;
371371
DEVELOPMENT_TEAM = UV3HUS49VJ;
372372
ENABLE_HARDENED_RUNTIME = YES;
373373
GENERATE_INFOPLIST_FILE = YES;
@@ -380,7 +380,7 @@
380380
"$(inherited)",
381381
"@executable_path/../Frameworks",
382382
);
383-
MARKETING_VERSION = 1.1;
383+
MARKETING_VERSION = 1.3;
384384
PRODUCT_BUNDLE_IDENTIFIER = "com.pavelmakhov.streak-bar";
385385
PRODUCT_NAME = "$(TARGET_NAME)";
386386
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -396,7 +396,7 @@
396396
CODE_SIGN_ENTITLEMENTS = "streak-bar/streak_bar.entitlements";
397397
CODE_SIGN_STYLE = Automatic;
398398
COMBINE_HIDPI_IMAGES = YES;
399-
CURRENT_PROJECT_VERSION = 2;
399+
CURRENT_PROJECT_VERSION = 5;
400400
DEVELOPMENT_TEAM = UV3HUS49VJ;
401401
ENABLE_HARDENED_RUNTIME = YES;
402402
GENERATE_INFOPLIST_FILE = YES;
@@ -409,7 +409,7 @@
409409
"$(inherited)",
410410
"@executable_path/../Frameworks",
411411
);
412-
MARKETING_VERSION = 1.1;
412+
MARKETING_VERSION = 1.3;
413413
PRODUCT_BUNDLE_IDENTIFIER = "com.pavelmakhov.streak-bar";
414414
PRODUCT_NAME = "$(TARGET_NAME)";
415415
SWIFT_EMIT_LOC_STRINGS = YES;

streak-bar/streak-bar/GitHub/Client.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import Defaults
1111

1212
public class Client {
1313

14-
@Default(.githubUsername) var githubUsername
1514
@FromKeychain(.githubToken) var githubToken
1615

1716
func getContributions(from: Date, completion: @escaping (Result<[ContributionWeek], ClientError>) -> Void) {
@@ -49,7 +48,7 @@ public class Client {
4948
var variables: [String: Any] = [:]
5049

5150
// Adding values to the dictionary
52-
variables["userName"] = githubUsername
51+
variables["userName"] = Defaults[.githubUsername]
5352
variables["from"] = formatDateToCustomString(from)
5453
variables["to"] = formatDateToCustomString(.now)
5554

streak-bar/streak-bar/ViewModel.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@ import Foundation
99
import Defaults
1010

1111
class ViewModel: ObservableObject {
12-
@Default(.daysBefore) var daysBefore
13-
@Default(.viewMode) var viewMode
1412

1513
private var client = Client()
1614

1715
@Published var contributions: [ContributionWeek] = []
1816

17+
init() {
18+
print("ViewModel init")
19+
}
20+
1921
func getContributions() {
20-
let multiplier = viewMode == .week ? 7 : 1
22+
let multiplier = Defaults[.viewMode] == .week ? 7 : 1
2123

22-
let fromDate = getDateNDaysBeforeToday(n: daysBefore * multiplier)
24+
let fromDate = getDateNDaysBeforeToday(n: Defaults[.daysBefore] * multiplier)
2325

2426
client.getContributions(from: fromDate) { result in
2527
switch result {

streak-bar/streak-bar/Views/ContentView.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ import LaunchAtLogin
1111
struct ContentView: View {
1212

1313
var appDelegate: AppDelegate
14-
@State private var favoriteColor = 0
14+
@State private var selectedTab = 0
1515

1616
var body: some View {
1717

1818
VStack(spacing: 10) {
1919
ZStack {
20-
Picker("", selection: $favoriteColor) {
21-
Text("Settings").tag(0)
22-
Text("About").tag(1)
20+
Picker("", selection: $selectedTab) {
21+
Text("Streaks").tag(0)
22+
Text("Settings").tag(1)
23+
Text("About").tag(2)
2324
}
2425
.pickerStyle(.segmented)
2526
.frame(width: 150)
@@ -49,9 +50,12 @@ struct ContentView: View {
4950
}
5051
}
5152

52-
if favoriteColor == 0 {
53+
if selectedTab == 0 {
54+
StatusItemView(viewModel: appDelegate.viewModel, isFullSize: true)
55+
.padding()
56+
} else if selectedTab == 1 {
5357
SettingsView(appDelegate: appDelegate)
54-
} else {
58+
} else if selectedTab == 2 {
5559
AboutView()
5660
}
5761
}

streak-bar/streak-bar/Views/StatusItemView.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ struct StatusItemView: View {
1515
@Default(.borders) var borders
1616
@Default(.transparency) var transparency
1717
@Default(.viewMode) var viewMode
18-
18+
19+
var isFullSize: Bool = false
20+
1921
var body: some View {
2022

2123
if viewModel.contributions.first?.contributionDays.isEmpty ?? false {
@@ -31,7 +33,7 @@ struct StatusItemView: View {
3133
ForEach(week.contributionDays, id:\.date) { day in
3234
Rectangle()
3335
.fill(Theme.themes[theme]![day.contributionLevel]!.opacity(day.contributionLevel == .NONE && !transparency ? 0.2 : 1))
34-
.frame(width: borders ? 2 : 3, height: borders ? 2 : 3)
36+
.frame(width: (borders ? 2 : 3) * (isFullSize ? 3 : 1), height: (borders ? 2 : 3) * (isFullSize ? 3 : 1))
3537
}
3638
}
3739
}
@@ -42,7 +44,7 @@ struct StatusItemView: View {
4244
ForEach(week.contributionDays, id:\.date) { day in
4345
RoundedRectangle(cornerRadius: 4)
4446
.fill(Theme.themes[theme]![day.contributionLevel]!.opacity(day.contributionLevel == .NONE && !transparency ? 0.2 : 1))
45-
.frame(width: 16, height: 16)
47+
.frame(width: 16 * (isFullSize ? 3 : 1), height: 16 * (isFullSize ? 3 : 1))
4648
}
4749
}
4850
}

0 commit comments

Comments
 (0)