switch db between debug and release

on widgets if its before the voting time show yesterdays vote, if after either show no vote or current vote

user shared user defaults
This commit is contained in:
Trey t
2022-01-28 10:27:33 -06:00
parent a45c2f0639
commit 0109aee8f8
6 changed files with 30 additions and 12 deletions

View File

@@ -28,8 +28,13 @@ class WatchTimelineView: Identifiable {
struct TimeLineCreator {
static func createViews(daysBack: Int) -> [WatchTimelineView] {
var timeLineView = [WatchTimelineView]()
var startDayOffset = 0
for day in 0..<daysBack{
if !UserDefaultsStore.getOnboarding().ableToVoteBasedOnCurentTime() {
startDayOffset = 1
}
for day in startDayOffset..<daysBack{
let day = Calendar.current.date(byAdding: .day, value: -day, to: Date())!
let dayStart = Calendar.current.startOfDay(for: day)
@@ -62,13 +67,13 @@ struct Provider: IntentTimelineProvider {
func placeholder(in context: Context) -> SimpleEntry {
return SimpleEntry(date: Date(),
configuration: ConfigurationIntent(),
timeLineViews: TimeLineCreator.createViews(daysBack: 10))
timeLineViews: Array(TimeLineCreator.createViews(daysBack: 11).prefix(10)))
}
func getSnapshot(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (SimpleEntry) -> ()) {
let entry = SimpleEntry(date: Date(),
configuration: ConfigurationIntent(),
timeLineViews: TimeLineCreator.createViews(daysBack: 10))
timeLineViews: Array(TimeLineCreator.createViews(daysBack: 11).prefix(10)))
completion(entry)
}
@@ -137,7 +142,7 @@ struct SmallWidgetView: View {
init(entry: Provider.Entry) {
self.entry = entry
timeLineView = TimeLineCreator.createViews(daysBack: 1)
timeLineView = [TimeLineCreator.createViews(daysBack: 2).first!]
}
var body: some View {
@@ -162,7 +167,7 @@ struct MediumWidgetView: View {
init(entry: Provider.Entry) {
self.entry = entry
timeLineView = TimeLineCreator.createViews(daysBack: 5)
timeLineView = Array(TimeLineCreator.createViews(daysBack: 6).prefix(5))
}
var body: some View {
@@ -205,7 +210,7 @@ struct SmallGraphicWidgetView: View {
init(entry: Provider.Entry) {
self.entry = entry
timeLineView = TimeLineCreator.createViews(daysBack: 1)
timeLineView = [TimeLineCreator.createViews(daysBack: 2).first!]
}
var body: some View {