Skip to content

Commit

Permalink
[#81] Add basic implementation of new UI
Browse files Browse the repository at this point in the history
Shows the first 4 tracks with accurate tick data. Ticking is not possible.
Create shared instance of TrackController for UIKit views to access.
  • Loading branch information
skjiisa committed Apr 23, 2022
1 parent 7687faa commit 38f760e
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 21 deletions.
14 changes: 13 additions & 1 deletion Tickmate/Tickmate.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
599D9F5225EC5A4900DF3795 /* TracksView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 599D9F5125EC5A4900DF3795 /* TracksView.swift */; };
59A0D8932645CF1600E01E61 /* View+DismissKeyboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59A0D8922645CF1600E01E61 /* View+DismissKeyboard.swift */; };
59BDBAF227E95A1C00F58704 /* TickView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5931643E26855EB8005DDA1A /* TickView.swift */; };
59BDBAF527E95C1300F58704 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 59BDBAF427E95C1300F58704 /* Main.storyboard */; };
59C23A6725E70D7000AFBC4B /* SymbolsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59C23A6625E70D7000AFBC4B /* SymbolsList.swift */; };
59C23A6C25E70E1A00AFBC4B /* SymbolPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59C23A6B25E70E1A00AFBC4B /* SymbolPicker.swift */; };
59D483C027057E3300CB30C0 /* View+Conditional.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59D483BF27057E3300CB30C0 /* View+Conditional.swift */; };
Expand Down Expand Up @@ -180,6 +181,7 @@
5996360E264F128A00AAF6CA /* GroupsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupsView.swift; sourceTree = "<group>"; };
599D9F5125EC5A4900DF3795 /* TracksView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TracksView.swift; sourceTree = "<group>"; };
59A0D8922645CF1600E01E61 /* View+DismissKeyboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+DismissKeyboard.swift"; sourceTree = "<group>"; };
59BDBAF427E95C1300F58704 /* Main.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
59C23A6625E70D7000AFBC4B /* SymbolsList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SymbolsList.swift; sourceTree = "<group>"; };
59C23A6B25E70E1A00AFBC4B /* SymbolPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SymbolPicker.swift; sourceTree = "<group>"; };
59D483BF27057E3300CB30C0 /* View+Conditional.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+Conditional.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -308,6 +310,7 @@
598BFD1227E9492500F202D6 /* Main Screen */ = {
isa = PBXGroup;
children = (
59BDBAF327E95C0500F58704 /* Storyboards */,
598BFD2127E9564E00F202D6 /* Views */,
598BFD1A27E94B6700F202D6 /* ViewControllers */,
59F0980125E081CC00667971 /* TicksView.swift */,
Expand All @@ -332,8 +335,8 @@
isa = PBXGroup;
children = (
598BFD1B27E94BA000F202D6 /* ViewController.swift */,
598BFD1F27E9545C00F202D6 /* TrackTableViewController.swift */,
598BFD2427E9577200F202D6 /* PageViewController.swift */,
598BFD1F27E9545C00F202D6 /* TrackTableViewController.swift */,
);
path = ViewControllers;
sourceTree = "<group>";
Expand All @@ -346,6 +349,14 @@
path = Views;
sourceTree = "<group>";
};
59BDBAF327E95C0500F58704 /* Storyboards */ = {
isa = PBXGroup;
children = (
59BDBAF427E95C1300F58704 /* Main.storyboard */,
);
path = Storyboards;
sourceTree = "<group>";
};
59C23A6925E70D7900AFBC4B /* Resources */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -589,6 +600,7 @@
5985C7F42698F3F800413FF2 /* Launch Screen.storyboard in Resources */,
59FBCF2825E07BD8007B114F /* Preview Assets.xcassets in Resources */,
59FBCF2525E07BD8007B114F /* Assets.xcassets in Resources */,
59BDBAF527E95C1300F58704 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 2 additions & 0 deletions Tickmate/Tickmate/Controllers/TrackController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import WidgetKit

class TrackController: NSObject, ObservableObject {

static var shared = TrackController()

//MARK: Properties

var tickControllers: [Track: TickController] = [:]
Expand Down
6 changes: 6 additions & 0 deletions Tickmate/Tickmate/TickmateApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ import SwiftUI
@main
struct TickmateApp: App {
let persistenceController = PersistenceController.shared

let newUI = false

var body: some Scene {
WindowGroup {
if newUI {
NewUI()
} else {
ContentView()
.environment(\.managedObjectContext, persistenceController.container.viewContext)
}
}
}
}
139 changes: 139 additions & 0 deletions Tickmate/Tickmate/UI/Main Screen/Storyboards/Main.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="xw8-Z1-Gt9">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Tickmate-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Tickmate" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3Vd-2s-JQj">
<rect key="frame" x="0.0" y="88" width="414" height="808"/>
<connections>
<segue destination="6CV-kh-VHQ" kind="embed" id="rif-K2-Jt9"/>
</connections>
</containerView>
<view userInteractionEnabled="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="U6n-Jf-edN">
<rect key="frame" x="0.0" y="88" width="100" height="808"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
<view userInteractionEnabled="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="cEp-nA-yVm">
<rect key="frame" x="0.0" y="88" width="100" height="808"/>
<subviews>
<tableView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="iAR-QT-TVJ">
<rect key="frame" x="0.0" y="0.0" width="100" height="808"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="TestCell" id="mbd-ph-KZM">
<rect key="frame" x="0.0" y="44.5" width="100" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="mbd-ph-KZM" id="wwo-1V-ldj">
<rect key="frame" x="0.0" y="0.0" width="100" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="BYZ-38-t0r" id="VjO-av-r2k"/>
<outlet property="delegate" destination="BYZ-38-t0r" id="fit-VF-iOt"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="0JV-MZ-ory"/>
<constraint firstItem="iAR-QT-TVJ" firstAttribute="top" secondItem="cEp-nA-yVm" secondAttribute="top" id="BjR-Or-vZ2"/>
<constraint firstItem="iAR-QT-TVJ" firstAttribute="leading" secondItem="cEp-nA-yVm" secondAttribute="leading" id="DML-aE-Ond"/>
<constraint firstAttribute="trailing" secondItem="iAR-QT-TVJ" secondAttribute="trailing" id="Zel-43-emM"/>
<constraint firstAttribute="bottom" secondItem="iAR-QT-TVJ" secondAttribute="bottom" id="hy9-AD-ii5"/>
</constraints>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="U6n-Jf-edN" firstAttribute="top" secondItem="cEp-nA-yVm" secondAttribute="top" id="4h2-dE-RSc"/>
<constraint firstItem="U6n-Jf-edN" firstAttribute="bottom" secondItem="cEp-nA-yVm" secondAttribute="bottom" id="EZy-f3-Fgb"/>
<constraint firstItem="3Vd-2s-JQj" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" id="Gg9-1g-oZy"/>
<constraint firstItem="U6n-Jf-edN" firstAttribute="leading" secondItem="cEp-nA-yVm" secondAttribute="leading" id="Iv7-rh-nZc"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="3Vd-2s-JQj" secondAttribute="trailing" id="MdQ-Dq-cjM"/>
<constraint firstAttribute="bottom" secondItem="3Vd-2s-JQj" secondAttribute="bottom" id="Mz7-BD-BH0"/>
<constraint firstItem="cEp-nA-yVm" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" id="SnI-3S-W3y"/>
<constraint firstItem="cEp-nA-yVm" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" id="V9w-Vm-rM9"/>
<constraint firstItem="3Vd-2s-JQj" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" id="eYd-iM-0mG"/>
<constraint firstAttribute="bottom" secondItem="cEp-nA-yVm" secondAttribute="bottom" id="kjB-QD-6Ok"/>
<constraint firstItem="U6n-Jf-edN" firstAttribute="trailing" secondItem="cEp-nA-yVm" secondAttribute="trailing" id="xaI-Kb-qeh"/>
</constraints>
</view>
<navigationItem key="navigationItem" title="Tickmate" largeTitleDisplayMode="never" id="L58-Bx-Ijc"/>
<connections>
<outlet property="shadowView" destination="U6n-Jf-edN" id="9hu-ZT-Wo3"/>
<outlet property="tableView" destination="iAR-QT-TVJ" id="Tl0-7X-qwT"/>
<outlet property="tableViewContainer" destination="cEp-nA-yVm" id="We5-iO-jcI"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="866.66666666666674" y="35.491071428571423"/>
</scene>
<!--Page View Controller-->
<scene sceneID="xwf-aQ-fTB">
<objects>
<pageViewController autoresizesArchivedViewToFullSize="NO" transitionStyle="scroll" navigationOrientation="horizontal" spineLocation="none" id="6CV-kh-VHQ" customClass="PageViewController" customModule="Tickmate" customModuleProvider="target" sceneMemberID="viewController"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="2wh-5k-zrS" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1721.7391304347827" y="34.821428571428569"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="hp8-9W-ZVc">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="xw8-Z1-Gt9" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="Z98-h0-KFp">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="7Jv-er-uEh"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="DMq-af-1NY" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-43.478260869565219" y="35.491071428571423"/>
</scene>
<!--Track Table View Controller-->
<scene sceneID="ftg-dX-0Zx">
<objects>
<tableViewController storyboardIdentifier="TrackTable" id="S51-u7-CMQ" customClass="TrackTableViewController" customModule="Tickmate" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" allowsSelection="NO" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" id="dV4-m5-NTX">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<connections>
<outlet property="dataSource" destination="S51-u7-CMQ" id="h6A-Om-LMw"/>
<outlet property="delegate" destination="S51-u7-CMQ" id="H5o-jP-kbs"/>
</connections>
</tableView>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="YnD-QP-3N1" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2613" y="35"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class PageViewController: UIPageViewController {

trackVC.index = index

let tracks = TrackController.shared.fetchedResultsController.fetchedObjects?.prefix(4)
trackVC.tracks = Array(tracks ?? [])

return trackVC
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@ import Combine

class TrackTableViewController: UITableViewController {

//MARK: Static

static let days = 100

//MARK: Properties

var index = 0
var scrollController: ScrollController = .shared
private var initialized = false
//TODO: Replace
private var tracks: [Track] = []
var tracks: [Track] = []

private var pagingSubscriber: AnyCancellable?

Expand Down Expand Up @@ -78,7 +74,7 @@ class TrackTableViewController: UITableViewController {
}

private func scrollToBottom(animated: Bool = false) {
let indexPath = IndexPath(row: Self.days-1, section: 0)
let indexPath = IndexPath(row: TickController.numDays-1, section: 0)
tableView.scrollToRow(at: indexPath, at: .top, animated: animated)
if initialized {
scrollController.contentOffset = tableView.contentOffset
Expand All @@ -93,7 +89,7 @@ class TrackTableViewController: UITableViewController {
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
Self.days
TickController.numDays
}

override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
Expand All @@ -103,7 +99,7 @@ class TrackTableViewController: UITableViewController {
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "DayCell", for: indexPath)
if let dayRow = cell as? DayTableViewCell {
dayRow.configure(with: tracks)
dayRow.configure(with: tracks, day: TickController.numDays - indexPath.row - 1)
}

scrollToDelegate()
Expand All @@ -130,7 +126,7 @@ class TrackTableViewController: UITableViewController {
guard scrollView.contentOffset != .zero,
!scrollController.isPaging else { return }
scrollController.contentOffset = scrollView.contentOffset
print(scrollView.contentOffset, "scrollViewDidScroll")
// print(scrollView.contentOffset, "scrollViewDidScroll")
}

override func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
Expand Down
Loading

0 comments on commit 38f760e

Please sign in to comment.