@@ -873,46 +873,8 @@ function text(input = null) {
873873 return displayText
874874}
875875
876- // Provide the SF Symbols battery icon depending on the battery level
877- function provideBatteryIcon ( ) {
878-
879- const batteryLevel = Device . batteryLevel ( )
880-
881- if ( Device . isCharging ( ) ) {
882-
883- let batIcon = SFSymbol . named ( "battery.100.bolt" )
884- batIcon . applyLightWeight ( )
885-
886- return batIcon . image
887-
888- } else
889-
890- if ( Math . round ( batteryLevel * 100 ) > 65 ) {
891-
892- let batIcon = SFSymbol . named ( "battery.100" )
893- batIcon . applyLightWeight ( )
894-
895- return batIcon . image
896-
897- } else if ( Math . round ( batteryLevel * 100 ) > 30 ) {
898-
899- let batIcon = SFSymbol . named ( "battery.25" )
900- batIcon . applyLightWeight ( )
901-
902- return batIcon . image
903-
904- } else {
905-
906- let batIcon = SFSymbol . named ( "battery.0" )
907- batIcon . applySemiboldWeight ( )
908-
909- return batIcon . image
910- }
911-
912- }
913-
914876// Add a battery element to the widget; consisting of a battery icon and percentage
915- async function battery ( column , alignment ) {
877+ async function battery ( column ) {
916878
917879 // Get battery level via Scriptable function and format it in a convenient way
918880 function getBatteryLevel ( ) {
@@ -926,7 +888,7 @@ async function battery(column, alignment) {
926888 const batteryLevel = Device . batteryLevel ( )
927889
928890 // Set up the battery level item
929- let batteryStack = align ( column , alignment )
891+ let batteryStack = align ( column )
930892 batteryStack . layoutHorizontally ( )
931893 batteryStack . centerAlignContent ( )
932894
@@ -988,6 +950,44 @@ function provideTextSymbol(shape) {
988950 return "\u2759"
989951}
990952
953+ // Provide the SF Symbols battery icon depending on the battery level
954+ function provideBatteryIcon ( ) {
955+
956+ const batteryLevel = Device . batteryLevel ( )
957+
958+ if ( Device . isCharging ( ) ) {
959+
960+ let batIcon = SFSymbol . named ( "battery.100.bolt" )
961+ batIcon . applyLightWeight ( )
962+
963+ return batIcon . image
964+
965+ } else
966+
967+ if ( Math . round ( batteryLevel * 100 ) > 65 ) {
968+
969+ let batIcon = SFSymbol . named ( "battery.100" )
970+ batIcon . applyLightWeight ( )
971+
972+ return batIcon . image
973+
974+ } else if ( Math . round ( batteryLevel * 100 ) > 30 ) {
975+
976+ let batIcon = SFSymbol . named ( "battery.25" )
977+ batIcon . applyLightWeight ( )
978+
979+ return batIcon . image
980+
981+ } else {
982+
983+ let batIcon = SFSymbol . named ( "battery.0" )
984+ batIcon . applySemiboldWeight ( )
985+
986+ return batIcon . image
987+ }
988+
989+ }
990+
991991// Provide a symbol based on the condition.
992992function provideSymbol ( cond , night ) {
993993
0 commit comments