Skip to content

Commit

Permalink
chore(App): improve layout anding version and endTime
Browse files Browse the repository at this point in the history
  • Loading branch information
victorwads committed Apr 11, 2023
1 parent 3a73541 commit 4f3c24c
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 14 deletions.
22 changes: 18 additions & 4 deletions Source/Models/LogItemInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,32 @@ extension LogItemInfo {
result += "\(seconds) seconds"
return result
}

var formattedStartUptime: String {
return formatDate(startUpTime)
}

var formattedEndtime: String {
if let data = endTime {
return " " + formatDate(data)
} else {
return ""
}
}

private func formatDate(_ date: Date) -> String {
let calendar = Calendar.current
let formatter = DateFormatter()
let at = Strings.dateAt.value

if calendar.isDateInToday(startUpTime) {
formatter.dateFormat = "'Today at' HH:mm:ss"
formatter.dateFormat = "'\(Strings.dateToday.value) \(at)' HH:mm:ss"
} else if calendar.isDateInYesterday(startUpTime) {
formatter.dateFormat = "'Yesterday at' HH:mm:ss"
formatter.dateFormat = "'\(Strings.dateYesterday.value) \(at)' HH:mm:ss"
} else {
formatter.dateFormat = "dd/MM/yyyy 'at' HH:mm:ss"
formatter.dateFormat = "dd/MM/yyyy '\(at)' HH:mm:ss"
}

return formatter.string(from: startUpTime)
return formatter.string(from: date)
}
}
4 changes: 4 additions & 0 deletions Source/String+Localized.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ enum Strings: String {
case installStep1Tip = "install.1.tip"
case installStep2 = "install.2"

case dateAt = "date.at"
case dateToday = "date.today"
case dateYesterday = "date.yesterday"

var value: String{
get { NSLocalizedString(self.rawValue, comment: "") }
}
Expand Down
3 changes: 2 additions & 1 deletion Source/View/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ struct ContentView: View {
Button(action: {
toggleCurrentAction()
}) {
Image(systemName: informed ? "" : "power")
Image(systemName: informed ? "arrow.counterclockwise.circle" : "power")
.font(.headline)
Text((informed ? Strings.mainCurrentCancel : Strings.mainCurrentInform).value)
}.help((informed ? Strings.mainCurrentCancelTip : Strings.mainCurrentInformTip).value)
}
Expand Down
21 changes: 14 additions & 7 deletions Source/View/LogItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ struct LogItemView: View {
}

var stack: some View {
HStack(alignment: .center) {
Image(systemName: allow ? "powersleep" : "bolt.slash.fill")
HStack(alignment: .center, spacing: 4) {
let info = (!allow ? Strings.logUnexpectedYes.value : Strings.logUnexpectedNo.value) + log.formattedEndtime
Text(info)
.foregroundColor(allow ? .green : .red)
Text(!allow ? Strings.logUnexpectedYes.value : Strings.logUnexpectedNo.value)
Image(systemName: allow ? "checkmark.seal.fill" : "bolt.trianglebadge.exclamationmark.fill")
.font(.headline)
.foregroundColor(allow ? .green : .red)
}
}
Expand All @@ -31,12 +33,14 @@ struct LogItemView: View {
HStack(alignment: .center) {
Image(systemName: "power")
Text(Strings.logStartup.value).bold()
Text("\(log.formattedStartUptime)")
}
Text(log.formattedStartUptime)
.font(.subheadline)
}.padding(.bottom, 2)
HStack(alignment: .center) {
Image(systemName: "clock")
Image(systemName: "bolt.badge.clock.fill")
Text(Strings.logUptime.value).bold()
Text("\(log.formattedUptime)")
Text(log.formattedUptime)
.font(.subheadline)
}
}
Spacer()
Expand All @@ -48,6 +52,9 @@ struct LogItemView: View {
stack.onTapGesture {
onToggleAction(log)
}.help(Strings.logHelp.value)
Divider()
Text("v\(log.version)")
.foregroundColor(.gray)
} else {
stack
}
Expand Down
4 changes: 2 additions & 2 deletions UptimeLogger.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = br.com.victorwads.UptimeLogger;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -530,7 +530,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = br.com.victorwads.UptimeLogger;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
5 changes: 5 additions & 0 deletions UptimeLogger/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@
"install.1" = "To install the service it's pretty simple, just click the continue button and a window will open where you must paste the command below and press enter:";
"install.1.tip" = "you must be an admin user";
"install.2" = "After running the command in the opened window, you must enter your user password and press enter (it is normal for characters to be invisible)\n\nUpon completion, you can click continue again.";

/* Date */
"date.at" = "at";
"date.today" = "Today";
"date.yesterday" = "Yesterday";
5 changes: 5 additions & 0 deletions UptimeLogger/pt-br.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@
"install.1" = "Para instalar o serviço é bem simples, basta clicar no botão continuar e será aberta uma janela onde você deve colar o comando abaixo e precionar enter:";
"install.1.tip" = "é necessário ser um usuário administrador";
"install.2" = "Após executar o comando na janela aberta, você deve inserir a senha do seu usuário e precionar enter (é normal que os caracteres fiquem invisiveis)\n\nAo finalizar, você pode clicar em continuar novamente.";

/* Date */
"date.at" = "às";
"date.today" = "Hoje";
"date.yesterday" = "Ontem";

0 comments on commit 4f3c24c

Please sign in to comment.