-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(App): mais informações sobre os logs.
- Loading branch information
1 parent
7a97eac
commit 7a4b0db
Showing
5 changed files
with
93 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters