Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
progress bar for expedition view
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerwooo committed Aug 11, 2022
1 parent d0536b7 commit 78227e8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
4 changes: 2 additions & 2 deletions PaimonMenuBar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 122;
CURRENT_PROJECT_VERSION = 123;
DEVELOPMENT_ASSET_PATHS = "\"PaimonMenuBar/Preview Content\"";
DEVELOPMENT_TEAM = W2HGAU9MPP;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -397,7 +397,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 122;
CURRENT_PROJECT_VERSION = 123;
DEVELOPMENT_ASSET_PATHS = "\"PaimonMenuBar/Preview Content\"";
DEVELOPMENT_TEAM = W2HGAU9MPP;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down
2 changes: 1 addition & 1 deletion PaimonMenuBar/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
}

let currentExpeditionNum = gameRecord.data.current_expedition_num
menuItemMain.frame = NSRect(x: 0, y: 0, width: 290, height: 292 + currentExpeditionNum * 28)
menuItemMain.frame = NSRect(x: 0, y: 0, width: 290, height: 292 + currentExpeditionNum * 36)
}

func updateStatusIcon() {
Expand Down
27 changes: 20 additions & 7 deletions PaimonMenuBar/MenuExtrasView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ struct ExpeditionView: View {
let currentExpeditionNum: Int

var body: some View {
VStack(spacing: 8) {
VStack(spacing: 10) {
HStack {
Text("Expeditions \(currentExpeditionNum)/\(maxExpeditionNum)")
.font(.subheadline)
Expand All @@ -198,18 +198,31 @@ struct ExpeditionItemView: View {
let avatar: String
let remainedTime: String

// 20 hours in seconds
let totalExpeditionTime: Float = 20 * 60 * 60

var body: some View {
HStack {
KFImage.url(URL(string: avatar))
.resizable()
.placeholder { Color.gray.opacity(0.3) }
.clipShape(Circle())
.overlay(Circle().stroke(status == "Finished" ? Color.green : Color.gray))
.frame(width: 20, height: 20)
Text(status == "Finished" ? String.localized("Complete") : String.localized("Exploring"))
Spacer()
Text(formatTimeInterval(timeInterval: remainedTime))
.font(.custom("Avenir Next Demi Bold", size: 13, relativeTo: .body).italic())
.frame(width: 22, height: 22)

VStack(spacing: 6) {
HStack {
Text(status == "Finished" ? String.localized("Complete") : String.localized("Exploring"))
Spacer()
Text(formatTimeInterval(timeInterval: remainedTime))
.font(.custom("Avenir Next Demi Bold", size: 13, relativeTo: .body).italic())
}

ProgressView(value: totalExpeditionTime - (Float(remainedTime) ?? 0), total: totalExpeditionTime)
.progressViewStyle(LinearProgressViewStyle(tint: status == "Finished" ?
Color.green : Color(red: 0.89, green: 0.90, blue: 0.92)))
.frame(height: 1).scaleEffect(x: 1, y: 0.4, anchor: .center)
}
}
}
}
Expand Down Expand Up @@ -302,6 +315,6 @@ struct MenuView_Previews: PreviewProvider {
static var previews: some View {
MenuExtrasView()
.frame(width: 290.0)
.frame(height: 426.0)
.frame(height: 472.0)
}
}

0 comments on commit 78227e8

Please sign in to comment.