Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
s2mr committed Aug 18, 2018
1 parent 776dc94 commit 2ac74e9
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 40 deletions.
2 changes: 1 addition & 1 deletion SimpleWallet/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
window = UIWindow()
window?.makeKeyAndVisible()
let tabBarController = UITabBarController()
let viewControllers = [TopTableViewController.make(),
let viewControllers = [ UINavigationController(rootViewController: TopTableViewController.make()),
WalletViewController.make(),
HomeViewController.make()]
viewControllers.forEach {
Expand Down
15 changes: 15 additions & 0 deletions SimpleWallet/Modules/Models/Post.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,19 @@ struct Post {
let deadline: Date

var voteCount = 0

static let dateFormatter: DateFormatter = {
let df = DateFormatter()
df.dateFormat = "MM/dd HH:mm:ss"
return df
}()
}

extension Array where Element == Post.Choice {
func get(at index: Int) -> Element? {
if index < count {
return self[index]
}
return nil
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,69 +19,69 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="profile" translatesAutoresizingMaskIntoConstraints="NO" id="kHS-ZW-k7b">
<rect key="frame" x="16" y="36" width="64" height="64"/>
<rect key="frame" x="16" y="131" width="64" height="64"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="〇〇大学" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FAf-VO-uj9">
<rect key="frame" x="88" y="36" width="70" height="21"/>
<rect key="frame" x="88" y="131" width="70" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="8/18 14:23" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fuv-gQ-q1p">
<rect key="frame" x="166" y="36" width="82" height="21"/>
<rect key="frame" x="166" y="131" width="202" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="〇〇大学第26回ミスコンです。" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uV7-J7-ReX">
<rect key="frame" x="88" y="65" width="246" height="21"/>
<rect key="frame" x="88" y="160" width="246" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uTa-x3-tfH">
<rect key="frame" x="156.5" y="152" width="62" height="30"/>
<rect key="frame" x="156.5" y="247" width="62" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="佐藤さん"/>
<connections>
<action selector="voteAction:" destination="33N-le-wLC" eventType="touchUpInside" id="ORg-Xl-smX"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="7Tf-wT-1Di">
<rect key="frame" x="156" y="190" width="62" height="30"/>
<rect key="frame" x="156" y="285" width="62" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="田中さん"/>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vR6-ZR-FTg">
<rect key="frame" x="156" y="235" width="62" height="30"/>
<rect key="frame" x="156" y="330" width="62" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="鈴木さん"/>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="IyP-ZM-D39">
<rect key="frame" x="156" y="273" width="62" height="30"/>
<rect key="frame" x="156" y="368" width="62" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="清水さん"/>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="300票" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VRR-0U-Fui">
<rect key="frame" x="31" y="421" width="49" height="21"/>
<rect key="frame" x="31" y="516" width="49" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="残り1日と12時間" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="anX-OQ-m5L">
<rect key="frame" x="123" y="421" width="129" height="21"/>
<rect key="frame" x="123" y="516" width="252" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="RXj-dg-e6z">
<rect key="frame" x="88" y="318" width="200" height="30"/>
<rect key="frame" x="88" y="413" width="200" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
Expand All @@ -92,7 +92,16 @@
<viewLayoutGuide key="safeArea" id="Vg4-im-3zk"/>
</view>
<connections>
<outlet property="choice1Button" destination="uTa-x3-tfH" id="bYE-U8-9at"/>
<outlet property="choice2Button" destination="7Tf-wT-1Di" id="b4A-fa-EYf"/>
<outlet property="choice3Button" destination="vR6-ZR-FTg" id="ZoE-0a-mx2"/>
<outlet property="choice4Button" destination="IyP-ZM-D39" id="ycw-6N-gc3"/>
<outlet property="commentText" destination="RXj-dg-e6z" id="coa-Ur-e5I"/>
<outlet property="dateLabel" destination="fuv-gQ-q1p" id="xC2-OX-HSg"/>
<outlet property="descriptionLabel" destination="uV7-J7-ReX" id="nRY-Tc-Svd"/>
<outlet property="remainDateLabel" destination="anX-OQ-m5L" id="Ykk-zC-581"/>
<outlet property="userNameLabel" destination="FAf-VO-uj9" id="eyw-gl-Jne"/>
<outlet property="voteCountLabel" destination="VRR-0U-Fui" id="NWc-pe-DaP"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="O84-1v-MZG" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,24 @@ import UIKit
import BitcoinKit

class DetailViewController: UIViewController {

@IBOutlet weak var userNameLabel: UILabel!
@IBOutlet weak var dateLabel: UILabel!
@IBOutlet weak var descriptionLabel: UILabel!
@IBOutlet weak var commentText: UITextField!

static func make() -> DetailViewController {
return R.storyboard.detailViewController.instantiateInitialViewController()!
@IBOutlet weak var choice1Button: UIButton!
@IBOutlet weak var choice2Button: UIButton!
@IBOutlet weak var choice3Button: UIButton!
@IBOutlet weak var choice4Button: UIButton!
@IBOutlet weak var voteCountLabel: UILabel!
@IBOutlet weak var remainDateLabel: UILabel!

private var post: Post!
private var updateTimer: Timer!

static func make(post: Post) -> DetailViewController {
let vc = R.storyboard.detailViewController.instantiateInitialViewController()!
vc.post = post
return vc
}

@IBAction func voteAction(_ sender: Any) {
Expand Down Expand Up @@ -141,24 +154,33 @@ class DetailViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

// Do any additional setup after loading the view.
setup(post: post)
updateTimer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { [weak self] _ in
guard let me = self else { return }
me.setup(post: me.post)
}
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

func setup(post: Post) {
userNameLabel.text = post.userName

/*
// MARK: - Navigation
let diff = Int(post.deadline.timeIntervalSince(Date()))
let day = diff/24/60/60
let hour = diff/60/60
let min = diff/60 - hour*60
let sec = diff - min*60 - hour*60*60

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
dateLabel.text = Post.dateFormatter.string(from: post.createdAt)
descriptionLabel.text = post.description
remainDateLabel.text = "残り\(day)日と\(hour)時間\(min)\(sec)"
choice1Button.setTitle(post.choices.get(at: 0)?.description, for: .normal)
choice2Button.setTitle(post.choices.get(at: 1)?.description, for: .normal)
choice3Button.setTitle(post.choices.get(at: 2)?.description, for: .normal)
choice4Button.setTitle(post.choices.get(at: 3)?.description, for: .normal)
}
*/

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
updateTimer.invalidate()
}
}
16 changes: 8 additions & 8 deletions SimpleWallet/Modules/ViewControllers/Top/TopTableViewCell.xib
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" rowHeight="289" id="KGk-i7-Jjw" customClass="TopTableViewCell" customModule="SimpleWallet" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="320" height="289"/>
<rect key="frame" x="0.0" y="0.0" width="655" height="289"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="288.5"/>
<rect key="frame" x="0.0" y="0.0" width="655" height="288.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="8/12 12:00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2Mt-YN-GOY">
<rect key="frame" x="135" y="32" width="81" height="21"/>
<rect key="frame" x="135" y="32" width="232" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="description" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WVS-JG-2Yi">
<rect key="frame" x="30" y="61" width="86" height="21"/>
<rect key="frame" x="34" y="61" width="86" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="cng-dy-3H6">
<rect key="frame" x="30" y="102" width="224" height="91"/>
<rect key="frame" x="34" y="102" width="551" height="91"/>
<color key="backgroundColor" red="0.29085952043533325" green="0.20994566380977631" blue="0.14615128934383392" alpha="1" colorSpace="calibratedRGB"/>
</stackView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="0票" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2Pk-X7-LYr">
Expand All @@ -44,14 +44,14 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="残り3日と4時間" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="e4j-mk-tud">
<rect key="frame" x="117" y="233" width="139" height="21"/>
<rect key="frame" x="117" y="233" width="287" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="ユーザ名" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aGO-zZ-gR7">
<rect key="frame" x="30" y="31" width="70" height="21"/>
<rect key="frame" x="34" y="31" width="70" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
Expand All @@ -77,7 +77,7 @@
<outlet property="userNameLabel" destination="aGO-zZ-gR7" id="xA0-K3-RYD"/>
<outlet property="voteCountLabel" destination="2Pk-X7-LYr" id="3Ed-cr-VOV"/>
</connections>
<point key="canvasLocation" x="34" y="176.5"/>
<point key="canvasLocation" x="201.5" y="176.5"/>
</tableViewCell>
</objects>
</document>
Loading

0 comments on commit 2ac74e9

Please sign in to comment.