mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-01-19 05:45:15 +01:00
Merge pull request #2635 from BlueWallet/graphicRectangular
ADD: graphicRectangular complication
This commit is contained in:
commit
c4c6ab4cf2
@ -40,10 +40,11 @@ class ComplicationController: NSObject, CLKComplicationDataSource {
|
||||
let date: Date
|
||||
let valueLabel: String
|
||||
let currencySymbol: String
|
||||
|
||||
if let price = marketData?.formattedRateForComplication, let marketDatadata = marketData?.date {
|
||||
let timeLabel: String
|
||||
if let price = marketData?.formattedRateForComplication, let marketDatadata = marketData?.date, let lastUpdated = marketData?.formattedDate {
|
||||
date = marketDatadata
|
||||
valueLabel = price
|
||||
timeLabel = lastUpdated
|
||||
if let preferredFiatCurrency = UserDefaults.standard.string(forKey: "preferredFiatCurrency"), let preferredFiatUnit = fiatUnit(currency: preferredFiatCurrency) {
|
||||
currencySymbol = preferredFiatUnit.symbol
|
||||
} else {
|
||||
@ -51,6 +52,7 @@ class ComplicationController: NSObject, CLKComplicationDataSource {
|
||||
}
|
||||
} else {
|
||||
valueLabel = "--"
|
||||
timeLabel = "--"
|
||||
currencySymbol = fiatUnit(currency: "USD")!.symbol
|
||||
date = Date()
|
||||
}
|
||||
@ -131,7 +133,7 @@ class ComplicationController: NSObject, CLKComplicationDataSource {
|
||||
case .modularLarge:
|
||||
let template = CLKComplicationTemplateModularLargeStandardBody()
|
||||
if #available(watchOSApplicationExtension 6.0, *) {
|
||||
template.headerTextProvider = CLKTextProvider(format: "Bitcoin Market Price")
|
||||
template.headerTextProvider = CLKTextProvider(format: "Bitcoin Price")
|
||||
template.body1TextProvider = CLKTextProvider(format: "%@%@", currencySymbol, valueLabel)
|
||||
entry = CLKComplicationTimelineEntry(date: date, complicationTemplate: template)
|
||||
handler(entry)
|
||||
@ -143,8 +145,9 @@ class ComplicationController: NSObject, CLKComplicationDataSource {
|
||||
case .graphicRectangular:
|
||||
let template = CLKComplicationTemplateGraphicRectangularStandardBody()
|
||||
if #available(watchOSApplicationExtension 6.0, *) {
|
||||
template.headerTextProvider = CLKTextProvider(format: "Bitcoin Market Price")
|
||||
template.headerTextProvider = CLKTextProvider(format: "Bitcoin Price")
|
||||
template.body1TextProvider = CLKTextProvider(format: "%@%@", currencySymbol, valueLabel)
|
||||
template.body2TextProvider = CLKTextProvider(format: "%@", timeLabel)
|
||||
entry = CLKComplicationTimelineEntry(date: date, complicationTemplate: template)
|
||||
handler(entry)
|
||||
} else {
|
||||
@ -248,7 +251,7 @@ func getLocalizableSampleTemplate(for complication: CLKComplication, withHandler
|
||||
case .modularLarge:
|
||||
let template = CLKComplicationTemplateModularLargeStandardBody()
|
||||
if #available(watchOSApplicationExtension 6.0, *) {
|
||||
template.headerTextProvider = CLKTextProvider(format: "Bitcoin Market Price")
|
||||
template.headerTextProvider = CLKTextProvider(format: "Bitcoin Price")
|
||||
template.body1TextProvider = CLKTextProvider(format: "%@%@", "$S", "46,000")
|
||||
|
||||
handler(template)
|
||||
@ -260,8 +263,9 @@ func getLocalizableSampleTemplate(for complication: CLKComplication, withHandler
|
||||
case .graphicRectangular:
|
||||
let template = CLKComplicationTemplateGraphicRectangularStandardBody()
|
||||
if #available(watchOSApplicationExtension 6.0, *) {
|
||||
template.headerTextProvider = CLKTextProvider(format: "Bitcoin Market Price")
|
||||
template.headerTextProvider = CLKTextProvider(format: "Bitcoin Price")
|
||||
template.body1TextProvider = CLKTextProvider(format: "%@%@", "$S", "46,000")
|
||||
template.body2TextProvider = CLKTextProvider(format: "%@", Date().description)
|
||||
handler(template)
|
||||
} else {
|
||||
handler(nil)
|
||||
|
@ -27,6 +27,7 @@
|
||||
<string>CLKComplicationFamilyCircularSmall</string>
|
||||
<string>CLKComplicationFamilyGraphicBezel</string>
|
||||
<string>CLKComplicationFamilyGraphicCircular</string>
|
||||
<string>CLKComplicationFamilyGraphicRectangular</string>
|
||||
<string>CLKComplicationFamilyGraphicCorner</string>
|
||||
<string>CLKComplicationFamilyModularLarge</string>
|
||||
<string>CLKComplicationFamilyModularSmall</string>
|
||||
|
@ -43,6 +43,17 @@ struct WidgetDataStore: Codable {
|
||||
|
||||
return isoDateFormatter.date(from: lastUpdate)
|
||||
}
|
||||
var formattedDate: String? {
|
||||
let isoDateFormatter = ISO8601DateFormatter()
|
||||
let dateFormatter = DateFormatter()
|
||||
dateFormatter.locale = Locale.current
|
||||
dateFormatter.timeStyle = .short
|
||||
|
||||
if let date = isoDateFormatter.date(from: lastUpdate) {
|
||||
return dateFormatter.string(from: date)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
class WidgetData {
|
||||
|
Loading…
Reference in New Issue
Block a user