Skip to content

Commit

Permalink
feat(Watch): Info sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
macmade committed Dec 14, 2024
1 parent 4fbc593 commit e3608db
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 5 deletions.
8 changes: 8 additions & 0 deletions SDO-Mobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
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 */; };
054DE7C82D0E08DC00A52D1A /* InfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054DE7C72D0E08D900A52D1A /* InfoView.swift */; };
054DE7CC2D0E0AD800A52D1A /* InfoDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054DE7CB2D0E0AD200A52D1A /* InfoDetailView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -140,6 +142,8 @@
054DE7712D0DDBB000A52D1A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = Info.plist; sourceTree = "<group>"; };
054DE7BF2D0DE37900A52D1A /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
054DE7C02D0DE37900A52D1A /* SDOApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SDOApp.swift; sourceTree = "<group>"; };
054DE7C72D0E08D900A52D1A /* InfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoView.swift; sourceTree = "<group>"; };
054DE7CB2D0E0AD200A52D1A /* InfoDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoDetailView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -388,6 +392,8 @@
isa = PBXGroup;
children = (
054DE7BF2D0DE37900A52D1A /* ContentView.swift */,
054DE7C72D0E08D900A52D1A /* InfoView.swift */,
054DE7CB2D0E0AD200A52D1A /* InfoDetailView.swift */,
054DE7C02D0DE37900A52D1A /* SDOApp.swift */,
);
path = Views;
Expand Down Expand Up @@ -531,8 +537,10 @@
054DE7A22D0DDFEB00A52D1A /* ImageInfo.swift in Sources */,
054DE7A32D0DDFEB00A52D1A /* SDO.swift in Sources */,
054DE7A42D0DDFEB00A52D1A /* ImageData.swift in Sources */,
054DE7CC2D0E0AD800A52D1A /* InfoDetailView.swift in Sources */,
054DE7BC2D0DE27F00A52D1A /* PreviewData.swift in Sources */,
054DE7A52D0DDFEB00A52D1A /* RuntimeError.swift in Sources */,
054DE7C82D0E08DC00A52D1A /* InfoView.swift in Sources */,
054DE7C62D0DE54500A52D1A /* TextButtonView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
27 changes: 22 additions & 5 deletions SDO-Watch/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct ContentView: View
@State private var images: [ ImageData ] = []
@State private var lastRefresh = Date()
@State private var isLoading = false
@State private var isShowingInfoSheet = false

var body: some View
{
Expand Down Expand Up @@ -67,12 +68,28 @@ struct ContentView: View

ForEach( self.images, id: \.uuid )
{
if let image = $0.image
info in if let image = info.image
{
Image( uiImage: image )
.resizable()
.aspectRatio( contentMode: .fill )
Text( $0.title )
VStack
{
Button()
{
self.isShowingInfoSheet = true
}
label:
{
Image( uiImage: image )
.resizable()
.aspectRatio( contentMode: .fill )
}
.disabled( info.text == nil )
.sheet( isPresented: $isShowingInfoSheet )
{
InfoView( image: info ).padding( .horizontal )
}
}
.buttonStyle( .borderless )
Text( info.title )
.font( .caption2 )
.bold()
.multilineTextAlignment( .center )
Expand Down
48 changes: 48 additions & 0 deletions SDO-Watch/Views/InfoDetailView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2023, Jean-David Gadina - www.xs-labs.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the Software), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/

import SwiftUI

struct InfoDetailView: View
{
@State public var title: String
@State public var text: String

var body: some View
{
VStack( alignment: .leading )
{
Text( self.title )
.font( .caption )
.foregroundStyle( .secondary )
Text( self.text )
.font( .caption )
}
}
}

#Preview
{
InfoDetailView( title: "Lorem ipsum:", text: "Lorem ipsum dolor sit amet, consectetuer adipiscing elit" ).padding()
}
73 changes: 73 additions & 0 deletions SDO-Watch/Views/InfoView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2023, Jean-David Gadina - www.xs-labs.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the Software), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/

import SwiftUI

struct InfoView: View
{
@State public var image: ImageData

var body: some View
{
ScrollView
{
VStack( alignment: .leading, spacing: 10 )
{
Text( self.image.title )
.font( .title3 )
.bold()

if let text = self.image.text
{
Text( text )
}

if let location = self.image.location
{
InfoDetailView( title: "Where:", text: location )
}

if let wavelength = self.image.wavelength
{
InfoDetailView( title: "Wavelength:", text: wavelength )
}

if let ions = self.image.ions
{
InfoDetailView( title: "Primary Ions Seen:", text: ions )
}

if let temperature = self.image.temperature
{
InfoDetailView( title: "Characteristic Temperature:", text: temperature )
}
}
}
}
}

#Preview
{
InfoView( image: PreviewData.images.first! )
}

0 comments on commit e3608db

Please sign in to comment.