Skip to content

Commit

Permalink
chore(App): mais informações sobre os logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
victorwads committed Apr 19, 2023
1 parent 7a97eac commit 7a4b0db
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 26 deletions.
12 changes: 3 additions & 9 deletions Source/Views/Screens/LogDetails/LogDetailsScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,10 @@ struct LogDetailsScreen: View {
}
} else {
VStack {
HStack {
Text(urlFileName)
.font(.title)
Spacer()
}
.padding(.horizontal)
.padding(.top)
LogItemView(log: $logFile)
.padding(.horizontal)
.frame(maxHeight: 50)
.padding(.top, 0)
.frame(maxHeight: 80)
if(logFile.hasProcess) {
if(processes.count == 0){
Spacer()
Expand All @@ -62,7 +56,7 @@ struct LogDetailsScreen: View {
DispatchQueue.global().async {
processes = provider.loadProccessLogFor(filename: urlFileName)
}
}
}.navigationTitle(urlFileName)
}
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Views/Screens/LogDetails/ProcessView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct ProcessView: View {

var body: some View {
Divider()
.padding(.top, 10)
.padding(.top, 0)
HStack {
Picker("Sort by", selection: $sortingOption) {
Text("Command").tag(SortingOption.command)
Expand All @@ -49,7 +49,7 @@ struct ProcessView: View {
.pickerStyle(SegmentedPickerStyle())
.padding(.horizontal)
HStack {
TextField("Search command", text: $searchText)
TextField("Search", text: $searchText)
.textFieldStyle(RoundedBorderTextFieldStyle())
Image(systemName: "magnifyingglass")
.foregroundColor(.gray)
Expand Down
58 changes: 58 additions & 0 deletions Source/Views/Screens/Logs/Battery.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// Battery.swift
// UptimeLogger
//
// Created by Victor Wads on 19/04/23.
//

import SwiftUI

struct Battery: View {
enum BatteryIcon: String {
case battery0 = "battery.0"
case battery25 = "battery.25"
case battery50 = "battery.50"
case battery75 = "battery.75"
case battery100 = "battery.100"

static func fromBatteryLevel(_ level: Int) -> BatteryIcon {
switch level {
case 0...10:
return .battery0
case 11...35:
return .battery25
case 36...60:
return .battery50
case 61...85:
return .battery75
default:
return .battery100
}
}
}

let level: Int

var body: some View {
HStack {
Image(systemName: BatteryIcon.fromBatteryLevel(level).rawValue)
.foregroundColor(.accentColor)
Text("\(level)%")
}
}
}

struct Battery_Previews: PreviewProvider {
static var previews: some View {
Battery(level: 5)
Battery(level: 15)
Battery(level: 25)
Battery(level: 35)
Battery(level: 45)
Battery(level: 55)
Battery(level: 70)
Battery(level: 80)
Battery(level: 90)
Battery(level: 100)
}
}
41 changes: 26 additions & 15 deletions Source/Views/Screens/Logs/LogItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,12 @@ struct LogItemView: View {

var body: some View {
HStack(alignment: .center) {
HStack(alignment: .center) {
Image(systemName: LogItemView.iconScriptStartTime)
.foregroundColor(.accentColor)
MonoText(text: log.formattedStartUptime)
}.padding(.bottom, 2)
HStack(alignment: .center) {
Image(systemName: LogItemView.iconShutdownTime)
.foregroundColor(.accentColor)
MonoText(text: log.formattedShutdownTime ?? "null")
if(!showDetails) {
HStack(alignment: .center) {
Image(systemName: LogItemView.iconScriptStartTime)
.foregroundColor(.accentColor)
MonoText(text: log.formattedStartUptime)
}.padding(.bottom, 2)
}
HStack(alignment: .center) {
Image(systemName: LogItemView.iconBootTime)
Expand All @@ -62,9 +59,7 @@ struct LogItemView: View {
MonoText(text: log.formattedUptime)
}
Spacer()
// Text(Strings.logUnexpected.value).bold()
// .font(.subheadline)
// .foregroundColor(.gray)


shutdownStatus.onTapGesture {
if let onToggleAction = onToggleAction {
Expand All @@ -76,7 +71,23 @@ struct LogItemView: View {
Image(systemName: LogItemView.iconEdited)
.help(Strings.logEditedTip.value)
}
Divider()
HStack {
if let sys = log.systemVersion {
Divider()
HStack {
Image(systemName: "desktopcomputer")
.foregroundColor(.accentColor)
MonoText(text: sys)
}.help("versão do SO")
}
if let battery = log.batery, let charging = log.charging {
Divider()
Battery(level: battery)
Image(systemName: charging ? "bolt.fill" : "bolt.slash.fill")
.help(charging ? "conectado a energia" : "desconectado da energia")
Divider()
}
}
Text("v\(log.version)")
.foregroundColor(.gray)
if(showDetails) {
Expand All @@ -86,7 +97,7 @@ struct LogItemView: View {
openURL(url)
}
} label: {
Text("detalhes")
Image(systemName: "info.circle")
}
}
}
Expand Down Expand Up @@ -144,6 +155,6 @@ logprocess: true
log: .constant(LogItemInfo(fileName: fileName, content: content2)),
showDetails: true,
onToggleAction: {_ in }
)
).frame(minWidth: 1500, maxHeight: 60)
}
}
4 changes: 4 additions & 0 deletions UptimeLogger.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
93A8805729EF94CF005A4E1B /* ProcessView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93A8805629EF94CF005A4E1B /* ProcessView.swift */; };
93A8805929EF96AB005A4E1B /* ProcessItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93A8805829EF96AB005A4E1B /* ProcessItemView.swift */; };
93A8805B29EF97E6005A4E1B /* LogDetailsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93A8805A29EF97E6005A4E1B /* LogDetailsScreen.swift */; };
93A8805D29EFA072005A4E1B /* Battery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93A8805C29EFA072005A4E1B /* Battery.swift */; };
93AB39FC29E37737006BF0B9 /* LogItemInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93AB39FB29E37737006BF0B9 /* LogItemInfo.swift */; };
93BD359529E6F7A100CB30A9 /* LogsProvider+Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93BD359429E6F7A100CB30A9 /* LogsProvider+Settings.swift */; };
93BEA29329E46C4700280DAC /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 93BEA29129E46C4700280DAC /* Localizable.strings */; };
Expand Down Expand Up @@ -65,6 +66,7 @@
93A8805629EF94CF005A4E1B /* ProcessView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProcessView.swift; sourceTree = "<group>"; };
93A8805829EF96AB005A4E1B /* ProcessItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProcessItemView.swift; sourceTree = "<group>"; };
93A8805A29EF97E6005A4E1B /* LogDetailsScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogDetailsScreen.swift; sourceTree = "<group>"; };
93A8805C29EFA072005A4E1B /* Battery.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Battery.swift; sourceTree = "<group>"; };
93AB39FB29E37737006BF0B9 /* LogItemInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogItemInfo.swift; sourceTree = "<group>"; };
93BD359429E6F7A100CB30A9 /* LogsProvider+Settings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LogsProvider+Settings.swift"; sourceTree = "<group>"; };
93BEA29229E46C4700280DAC /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -113,6 +115,7 @@
93057FD429E3589900D1FD50 /* LogsListView.swift */,
938F6D6529E3B02E00DACB7A /* LogItemView.swift */,
930D124E29E6746C00456416 /* LegendView.swift */,
93A8805C29EFA072005A4E1B /* Battery.swift */,
);
path = Logs;
sourceTree = "<group>";
Expand Down Expand Up @@ -365,6 +368,7 @@
934DC48F29E63B640072A25C /* SettingsScreen.swift in Sources */,
93C2748729E3D5DB0033AB01 /* FilesProvider.swift in Sources */,
93AB39FC29E37737006BF0B9 /* LogItemInfo.swift in Sources */,
93A8805D29EFA072005A4E1B /* Battery.swift in Sources */,
93057FD529E3589900D1FD50 /* LogsListView.swift in Sources */,
93BD359529E6F7A100CB30A9 /* LogsProvider+Settings.swift in Sources */,
930D124F29E6746C00456416 /* LegendView.swift in Sources */,
Expand Down

0 comments on commit 7a4b0db

Please sign in to comment.