Skip to content

Commit

Permalink
Rewrite QR reader in SwiftUI (#17)
Browse files Browse the repository at this point in the history
Adds dependency on CodeScanner library and
refactors QR reader to SwiftUI view.
  • Loading branch information
jocmp committed Dec 2, 2023
1 parent 58ff2a6 commit 1ff9031
Show file tree
Hide file tree
Showing 13 changed files with 268 additions and 453 deletions.
241 changes: 49 additions & 192 deletions ArtAtGVSU.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions ArtAtGVSU.xcodeproj/xcshareddata/xcschemes/ArtAtGVSU.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@
isEnabled = "NO">
</CommandLineArgument>
</CommandLineArguments>
<DeviceSensorReplayFileReference
identifier = "../AR Session 10.mov">
</DeviceSensorReplayFileReference>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
15 changes: 0 additions & 15 deletions ArtAtGVSU/File.swift

This file was deleted.

34 changes: 34 additions & 0 deletions ArtAtGVSU/Links.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// Links.swift
// ArtAtGVSU
//
// Created by Josiah Campbell on 12/1/23.
// Copyright © 2023 Applied Computing Institute. All rights reserved.
//

import Foundation

struct Links {
static func artworkDetail(id: String) -> URL {
return URL(string: "https://artgallery.gvsu.edu/Detail/objects/\(id)")!
}

static func fromDetailLink(_ link: String) -> String? {
guard let url = URL(string: link) else {
return nil
}

if (!url.isDetailLink || url.pathComponents.isEmpty) {
return nil
}

return url.pathComponents.last
}
}

private extension URL {
var isDetailLink: Bool {
return scheme == "http" || scheme == "https" &&
host == "artgallery.gvsu.edu"
}
}
25 changes: 25 additions & 0 deletions ArtAtGVSU/Logging.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Logging.swift
// ArtAtGVSU
//
// Created by Josiah Campbell on 12/1/23.
// Copyright © 2023 Applied Computing Institute. All rights reserved.
//

import Foundation
import os.log

protocol Logging {
var logger: Logger { get }
static var logger: Logger { get }
}

extension Logging {
var logger: Logger {
Logger(subsystem: Bundle.main.bundleIdentifier!, category: String(describing: type(of: self)))
}

static var logger: Logger {
Logger(subsystem: Bundle.main.bundleIdentifier!, category: String(describing: type(of: self)))
}
}
15 changes: 8 additions & 7 deletions ArtAtGVSU/TabNavigationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ struct TabNavigationView: View {
.toolbar {
NavigationLink(
destination: SettingsView()
.navigationBarTitle("navigation_Settings", displayMode: .inline),
label: { Image(systemName: "gearshape") }
)
.navigationBarTitle("navigation_Settings", displayMode: .inline)
) {
Image(systemName: "gearshape")
}
}
.id(tabIDs[Tab.home])
}
Expand All @@ -55,9 +56,7 @@ struct TabNavigationView: View {
SearchIndexView()
.navigationBarTitle("navigation_Search", displayMode: .inline)
.toolbar {
NavigationLink(destination: ScanQRCodeRepresentable()) {
Image(systemName: "qrcode.viewfinder")
}
QRCodeReaderButton()
}
}
.tabItem {
Expand All @@ -69,7 +68,9 @@ struct TabNavigationView: View {
FavoritesIndexView()
.navigationBarTitle("navigation_Favorites", displayMode: .inline)
.toolbar {
Button(action: shareFavorites, label: { Image(systemName: "square.and.arrow.up") })
Button(action: shareFavorites) {
Image(systemName: "square.and.arrow.up")
}
}
}
.tabItem {
Expand Down
2 changes: 1 addition & 1 deletion ArtAtGVSU/Views/Artworks/ArtworkDetailController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ArtworkDetailController: UIViewController, ArtworkDetailDelegate, GalleryI
}

struct ArtworkDetailRepresentable: UIViewControllerRepresentable {
var artworkID: String
var artworkID: String?

func makeUIViewController(context: Context) -> ArtworkDetailController {
let controller = ArtworkDetailController()
Expand Down
46 changes: 6 additions & 40 deletions ArtAtGVSU/Views/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22155" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22131"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -447,7 +447,7 @@
<objects>
<tableViewController id="Kfm-LB-KMh" customClass="RelatedTableViewController" customModule="ArtAtGVSU" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="ZLn-Tc-tac">
<rect key="frame" x="0.0" y="0.0" width="414" height="838"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="886"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<prototypes>
Expand Down Expand Up @@ -483,7 +483,7 @@
<viewControllerLayoutGuide type="bottom" id="rqu-dW-7gi"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="EXy-UI-DIc">
<rect key="frame" x="0.0" y="0.0" width="414" height="838"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="886"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
Expand Down Expand Up @@ -622,46 +622,12 @@
</objects>
<point key="canvasLocation" x="1969" y="2187"/>
</scene>
<!--Scan Code View Controller-->
<scene sceneID="aLa-Oj-AFt">
<objects>
<viewController storyboardIdentifier="QRCodeScanner" id="s9D-q0-Kpe" customClass="ScanCodeViewController" customModule="ArtAtGVSU" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="A6S-wL-1b7"/>
<viewControllerLayoutGuide type="bottom" id="Egc-25-Yan"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="EhS-Y9-nVG">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="JUM-3R-pBb">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="JUM-3R-pBb" firstAttribute="height" secondItem="EhS-Y9-nVG" secondAttribute="height" id="1rY-Ag-vom"/>
<constraint firstItem="JUM-3R-pBb" firstAttribute="width" secondItem="EhS-Y9-nVG" secondAttribute="width" id="80v-qu-okt"/>
<constraint firstItem="JUM-3R-pBb" firstAttribute="centerX" secondItem="EhS-Y9-nVG" secondAttribute="centerX" id="Jst-ty-HTk"/>
<constraint firstItem="JUM-3R-pBb" firstAttribute="centerY" secondItem="EhS-Y9-nVG" secondAttribute="centerY" id="yxz-6J-yyA"/>
</constraints>
</view>
<connections>
<outlet property="viewPreview" destination="JUM-3R-pBb" id="hwH-BX-L7h"/>
<segue destination="PB0-RA-FIY" kind="show" identifier="ScanDetailSegue" id="eUX-RJ-WeY"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="pLv-n8-yUg" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2995" y="1414"/>
</scene>
<!--Featured Table View Controller-->
<scene sceneID="oqg-np-ehq">
<objects>
<tableViewController id="JBs-06-Urw" customClass="FeaturedTableViewController" customModule="ArtAtGVSU" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="U7D-Bx-Pft">
<rect key="frame" x="0.0" y="0.0" width="414" height="838"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="886"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<prototypes>
Expand Down Expand Up @@ -697,7 +663,7 @@
<viewControllerLayoutGuide type="bottom" id="ZzY-HS-WMP"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="qNL-Q9-nlX">
<rect key="frame" x="0.0" y="0.0" width="414" height="838"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="886"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No Text" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qnb-Lu-7H9">
Expand Down

0 comments on commit 1ff9031

Please sign in to comment.