Skip to content

Commit

Permalink
feat(Watch): Application in progress...
Browse files Browse the repository at this point in the history
  • Loading branch information
macmade committed Dec 14, 2024
1 parent e2eb4df commit 2189a7f
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 3 deletions.
2 changes: 2 additions & 0 deletions SDO-Mobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
054DE7C22D0DE37900A52D1A /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054DE7BF2D0DE37900A52D1A /* ContentView.swift */; };
054DE7C32D0DE37900A52D1A /* SDOApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054DE7C02D0DE37900A52D1A /* SDOApp.swift */; };
054DE7C42D0DE41600A52D1A /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 054DE6F82D0DD66F00A52D1A /* Preview Assets.xcassets */; };
054DE7C62D0DE54500A52D1A /* TextButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054DE71B2D0DD7FE00A52D1A /* TextButtonView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -532,6 +533,7 @@
054DE7A42D0DDFEB00A52D1A /* ImageData.swift in Sources */,
054DE7BC2D0DE27F00A52D1A /* PreviewData.swift in Sources */,
054DE7A52D0DDFEB00A52D1A /* RuntimeError.swift in Sources */,
054DE7C62D0DE54500A52D1A /* TextButtonView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file modified SDO-Watch/Info.plist
Binary file not shown.
97 changes: 94 additions & 3 deletions SDO-Watch/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,104 @@ import SwiftUI

struct ContentView: View
{
@State private var images: [ ImageData ] = []
@State private var lastRefresh = Date()
@State private var isLoading = false

var body: some View
{
VStack
ZStack
{
if self.images.isEmpty, self.isLoading == false
{
VStack( spacing: 10 )
{
Image( systemName: "sun.max.trianglebadge.exclamationmark.fill" )
.resizable()
.frame( width: 25, height: 25 )
.padding()
Button( "Refresh" )
{
self.refresh()
}
}
.padding()
}
else if self.images.isEmpty == false
{
ScrollView
{
VStack( spacing: 0 )
{
Button()
{
self.refresh()
}
label:
{
Label( "Refresh", systemImage: "arrow.trianglehead.2.counterclockwise" )
}
.buttonStyle( .borderless )

ForEach( self.images, id: \.uuid )
{
if let image = $0.image
{
Image( uiImage: image )
.resizable()
.aspectRatio( contentMode: .fill )
Text( $0.title )
.font( .caption2 )
.bold()
.multilineTextAlignment( .center )
.padding( 10 )
}
}
}
}
.blur( radius: self.isLoading ? 75 : 0 )
.disabled( self.isLoading )
}

if self.isLoading
{
VStack
{
ProgressView().scaleEffect( 1.5 ).padding()
Text( "Loading Images" ).foregroundStyle( .secondary ).multilineTextAlignment( .center )
}
}
}
.onAppear
{
self.refresh()
}
}

private func refresh()
{
self.isLoading = true

SDO.shared?.downloadAll
{
Text( "hello, world" )
images in DispatchQueue.main.asyncAfter( deadline: .now() + .milliseconds( 500 ) )
{
self.lastRefresh = Date()
self.images = images.filter { $0.image != nil }
self.isLoading = false
}
}
.padding()
}

private var lastRefreshText: String
{
let formatter = DateFormatter()

formatter.dateStyle = .short
formatter.timeStyle = .short
formatter.doesRelativeDateFormatting = true

return formatter.string( from: self.lastRefresh )
}
}

Expand Down

0 comments on commit 2189a7f

Please sign in to comment.