Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storyboard replacement/Home #130

Draft
wants to merge 26 commits into
base: change/storyboard_to_uikit_code
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2a2bc5e
add: KUIDropdownTextField
shusuke0812 Jun 15, 2024
b048618
fix: replace cultivationStartDateTextField to KUIDropdownTextField
shusuke0812 Jun 15, 2024
62bf767
add: KUIRoundedViewProps
shusuke0812 Jun 15, 2024
1f01b4e
add: KUILabelWithImage
shusuke0812 Jun 16, 2024
b899e24
add: KUIHomeAdviceView
shusuke0812 Jun 16, 2024
211b8b0
fix: KUILabelWithImage init
shusuke0812 Jun 16, 2024
ee9308a
add: updateDescription() in HomeAdviceView
shusuke0812 Jun 16, 2024
24d9aa7
fix: by swiftformat
shusuke0812 Jun 16, 2024
ff1d92c
rename: FooterButtonView to KUIFooterButtonView
shusuke0812 Jun 17, 2024
b994761
move: KUIFooterButtonview to KikurageUI
shusuke0812 Jun 17, 2024
cd8744e
change: `FontAwesome.swift` dependency
shusuke0812 Jun 17, 2024
80d479a
move: Constants.Color to KikurageUI
shusuke0812 Jun 17, 2024
e11b144
move: UIColor+Extension to KikurageUI
shusuke0812 Jun 17, 2024
8b7dbb8
fix: build error
shusuke0812 Jun 17, 2024
aec1ee6
fix: by swiftformat
shusuke0812 Jun 17, 2024
2a32516
add: KUIDividerView
shusuke0812 Jun 29, 2024
8046fe1
fix: KUIHomeAdviceView base view
shusuke0812 Jun 29, 2024
7775c66
add: KUIDeviceStatusListView
shusuke0812 Jun 30, 2024
89639d6
fix: use default value when init KikurageUI/Atoms/KUIRoundedView.swift
shusuke0812 Jun 30, 2024
24bf24c
fix: use default value when init KUIDividerView
shusuke0812 Jun 30, 2024
80d6dbc
add: KUIDeviceStatusImageView
shusuke0812 Jul 6, 2024
a11a080
add: `KikurageData` embedded framework
shusuke0812 Jul 13, 2024
ec07f24
fix: integrate `KikurageData` in `KikurageUI`
shusuke0812 Jul 13, 2024
f29ecff
change: access level
shusuke0812 Jul 13, 2024
f9039c4
rename: `KikurageData` to `KikurageDomain`
shusuke0812 Jul 14, 2024
b7fc650
Fix HomeBaseView
shusuke0812 Sep 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
458 changes: 450 additions & 8 deletions Kikurage.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

28 changes: 0 additions & 28 deletions Kikurage/Constant/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,32 +63,4 @@ enum Constants {
enum Email {
static let address = "[email protected]"
}

enum Color: RawRepresentable {
case cultivation
case recipe
case communication

typealias RawValue = UIColor

init?(rawValue: RawValue) {
switch rawValue {
case UIColor(hex: "4A90E2"): self = .cultivation
case UIColor(hex: "F5A623"): self = .recipe
case UIColor(hex: "7ED321"): self = .communication
default: return nil
}
}

var rawValue: RawValue {
switch self {
case .cultivation:
return UIColor(hex: "4A90E2")
case .recipe:
return UIColor(hex: "F5A623")
case .communication:
return UIColor(hex: "7ED321")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protocol DeviceRegisterBaseViewDelegate: AnyObject {
class DeviceRegisterBaseView: UIView {
private(set) var productKeyTextField: KUITextField!
private(set) var kikurageNameTextField: KUITextField!
private(set) var cultivationStartDateTextField: KUITextField!
private(set) var cultivationStartDateTextField: KUIDropdownTextField!
private(set) var qrcodeReaderView: KikurageQRCodeReaderView!
private var deviceRegisterButton: KUIButton!
private var qrcodeReaderButton: UIButton!
Expand All @@ -28,12 +28,9 @@ class DeviceRegisterBaseView: UIView {

weak var delegate: DeviceRegisterBaseViewDelegate?

var datePicker = UIDatePicker()

override init(frame: CGRect) {
super.init(frame: .zero)
setupComponent()
setupDatePicker()
setupButtonAction()
}

Expand All @@ -52,8 +49,9 @@ class DeviceRegisterBaseView: UIView {
placeHolder: R.string.localizable.screen_device_register_kikurage_name_textfield_placeholer()
))

cultivationStartDateTextField = KUITextField(props: KUITextFieldProps(
placeHolder: R.string.localizable.screen_device_register_cultivation_start_date_textfield_placeholer()
cultivationStartDateTextField = KUIDropdownTextField(props: KUIDropDownTextFieldProps(
variant: .date,
textFieldProps: KUITextFieldProps(placeHolder: R.string.localizable.screen_device_register_cultivation_start_date_textfield_placeholer())
))

qrcodeReaderButton = UIButton(type: .system)
Expand Down Expand Up @@ -107,15 +105,6 @@ class DeviceRegisterBaseView: UIView {
hideQrcodeReaderViewConstraint = qrcodeReaderView.heightAnchor.constraint(equalToConstant: 0)
}

private func setupDatePicker() {
datePicker.preferredDatePickerStyle = .wheels
datePicker.datePickerMode = .date
datePicker.timeZone = NSTimeZone.local
datePicker.locale = Locale.current

cultivationStartDateTextField.inputView = datePicker
}

// MARK: - Action

private func setupButtonAction() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ extension DeviceRegisterViewController: UITextFieldDelegate {
}

private func setCultivationStartDateTextFieldData() {
let date: Date = baseView.datePicker.date
let date: Date = baseView.cultivationStartDateTextField.date
let dataString: String = DateHelper.formatToString(date: date)
baseView.cultivationStartDateTextField.text = dataString
viewModel.kikurageUser?.cultivationStartDate = date
Expand Down
116 changes: 52 additions & 64 deletions Kikurage/Screen/Home/BaseView/HomeBaseView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,32 @@
// Copyright © 2020 shusuke. All rights reserved.
//

import KikurageUI
import UIKit

class HomeBaseView: UIView {
@IBOutlet private weak var kikurageNameLabel: UILabel!
@IBOutlet private weak var kikurageStatusLabel: UILabel!

@IBOutlet private weak var kikurageStatusParentView: UIView!
@IBOutlet private weak var kikurageStatusImageView: UIImageView!
@IBOutlet private weak var nowTimeLabel: UILabel!

@IBOutlet private weak var valueParentView: UIView!
@IBOutlet private weak var temperatureTitleLabel: UILabel!
@IBOutlet private weak var temparatureTextLabel: UILabel!
@IBOutlet private weak var humidityTitleLabel: UILabel!
@IBOutlet private weak var humidityTextLabel: UILabel!
@IBOutlet private weak var nowValueTitleLabel: UILabel!
@IBOutlet private weak var expectedValueTitleLabel: UILabel!
@IBOutlet private weak var expectedTemperatureLabel: UILabel!
@IBOutlet private weak var expectedHumidityLabel: UILabel!

@IBOutlet private weak var kikurageAdviceView: HomeAdviceView!
@IBOutlet private(set) weak var footerButtonView: FooterButtonView!

private var kikurageStateEmptyView: UIView!

override func awakeFromNib() {
super.awakeFromNib()
private var nameLabel: UILabel!
private var statusLabel: UILabel!

private var statusParentView: UIView!
private var statusImageView: KUIDeviceStatusImageView!
private var nowTimeLabel: UILabel!

private var statusListView: KUIDeviceStatusListView!
private var homeAdviceView: KUIHomeAdviceView!
private(set) var footerButtonView: KUIFooterButtonView!

private var stateEmptyView: UIView!

override init(frame: CGRect) {
super.init(frame: frame)
initUI()
initFailedUI()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

// MARK: - Initialized
Expand All @@ -44,30 +40,27 @@ extension HomeBaseView {
private func initUI() {
backgroundColor = .systemGroupedBackground

nowTimeLabel = UILabel()
nowTimeLabel.text = DateHelper.now()
kikurageNameLabel.text = ""
kikurageStatusLabel.text = ""

kikurageStatusParentView.clipsToBounds = true
kikurageStatusParentView.layer.cornerRadius = .viewCornerRadius
nameLabel = UILabel()
nameLabel.text = ""

valueParentView.backgroundColor = .systemGroupedBackground
nowValueTitleLabel.text = R.string.localizable.screen_home_temperature_humidity_now_title()
expectedValueTitleLabel.text = R.string.localizable.screen_home_temperature_humidity_expected_title()
statusLabel = UILabel()
statusLabel.text = ""

temperatureTitleLabel.text = R.string.localizable.screen_home_temperature_title()
temparatureTextLabel.text = "-"
expectedTemperatureLabel.text = "20-25°C"
statusParentView = UIView()
statusParentView.clipsToBounds = true
statusParentView.layer.cornerRadius = .viewCornerRadius

humidityTitleLabel.text = R.string.localizable.screen_home_humidity_title()
humidityTextLabel.text = "-"
expectedHumidityLabel.text = "80% " + R.string.localizable.screen_home_humidity_expected_suffix()
statusListView = KUIDeviceStatusListView(props: KUIDeviceStatusListViewProps(temperature: 0, humidity: 0))
statusListView.translatesAutoresizingMaskIntoConstraints = false
}

private func initFailedUI() {
kikurageStateEmptyView = UIView()
kikurageStateEmptyView.backgroundColor = .white
kikurageStateEmptyView.translatesAutoresizingMaskIntoConstraints = false
stateEmptyView = UIView()
stateEmptyView.backgroundColor = .white
stateEmptyView.translatesAutoresizingMaskIntoConstraints = false

let label = UILabel()
label.text = R.string.localizable.common_read_error()
Expand All @@ -76,11 +69,11 @@ extension HomeBaseView {
label.numberOfLines = 1
label.translatesAutoresizingMaskIntoConstraints = false

kikurageStateEmptyView.addSubview(label)
stateEmptyView.addSubview(label)

NSLayoutConstraint.activate([
label.centerXAnchor.constraint(equalTo: kikurageStateEmptyView.centerXAnchor),
label.centerYAnchor.constraint(equalTo: kikurageStateEmptyView.centerYAnchor)
label.centerXAnchor.constraint(equalTo: stateEmptyView.centerXAnchor),
label.centerYAnchor.constraint(equalTo: stateEmptyView.centerYAnchor)
])
}
}
Expand All @@ -89,29 +82,28 @@ extension HomeBaseView {

extension HomeBaseView {
func setKikurageStateUI(kikurageState: KikurageState?) {
if let message: String = kikurageState?.message {
kikurageStatusLabel.text = message
if let message = kikurageState?.message {
statusLabel.text = message
}
if let type: KikurageStateType = kikurageState?.type {
displayKikurageStateImage(type: type)
} else {
displayFailedKikurageStateImage()
}
if let temparature: Int = kikurageState?.temperature, let humidity: Int = kikurageState?.humidity {
temparatureTextLabel.text = "\(temparature)"
humidityTextLabel.text = "\(humidity)"
if let temparature = kikurageState?.temperature, let humidity = kikurageState?.humidity {
statusListView.updateStatus(temperature: temparature, humidity: humidity)
}
if let advice: String = kikurageState?.advice {
kikurageAdviceView.setAdviceContentLabel(advice)
if let advice = kikurageState?.advice {
homeAdviceView.updateDescription(advice)
}
#if PRODUCTION
nowTimeLabel.isHidden = true
#endif
}

func setKikurageNameUI(kikurageUser: KikurageUser?) {
if let name: String = kikurageUser?.kikurageName {
kikurageNameLabel.text = R.string.localizable.screen_home_kikurage_name(name)
if let name = kikurageUser?.kikurageName {
nameLabel.text = R.string.localizable.screen_home_kikurage_name(name)
}
}

Expand All @@ -120,23 +112,19 @@ extension HomeBaseView {
}

private func displayKikurageStateImage(type: KikurageStateType) {
kikurageStateEmptyView.removeFromSuperview()
stateEmptyView.removeFromSuperview()
// 2つの画像を交互に表示する処理(アニメーションのSTOPはViewWillDisapperへ記載)
kikurageStatusImageView.animationImages = KikurageStateHelper.setStateImage(type: type)
kikurageStatusImageView.animationDuration = 1
kikurageStatusImageView.animationRepeatCount = 0
kikurageStatusImageView.startAnimating()
statusImageView.runAnimation(images: KikurageStateHelper.setStateImage(type: type))
}

private func displayFailedKikurageStateImage() {
kikurageStatusImageView.addSubview(kikurageStateEmptyView)
kikurageStatusImageView.image = nil
statusImageView.addSubview(stateEmptyView)

NSLayoutConstraint.activate([
kikurageStateEmptyView.topAnchor.constraint(equalTo: kikurageStatusImageView.topAnchor),
kikurageStateEmptyView.leadingAnchor.constraint(equalTo: kikurageStatusImageView.leadingAnchor),
kikurageStateEmptyView.trailingAnchor.constraint(equalTo: kikurageStatusImageView.trailingAnchor),
kikurageStateEmptyView.bottomAnchor.constraint(equalTo: kikurageStatusImageView.bottomAnchor)
stateEmptyView.topAnchor.constraint(equalTo: statusImageView.topAnchor),
stateEmptyView.leadingAnchor.constraint(equalTo: statusImageView.leadingAnchor),
stateEmptyView.trailingAnchor.constraint(equalTo: statusImageView.trailingAnchor),
stateEmptyView.bottomAnchor.constraint(equalTo: statusImageView.bottomAnchor)
])
}
}
Expand All @@ -145,6 +133,6 @@ extension HomeBaseView {

extension HomeBaseView {
func kikurageStatusViewAnimation(_ animation: Bool) {
(animation == true) ? kikurageStatusImageView.startAnimating() : kikurageStatusImageView.stopAnimating()
(animation == true) ? statusImageView.startAnimating() : statusImageView.stopAnimating()
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19162" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="HCp-ee-WbN">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="HCp-ee-WbN">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
<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"/>
Expand All @@ -18,19 +17,19 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1um-rs-6A0">
<rect key="frame" x="16" y="64" width="382" height="0.0"/>
<rect key="frame" x="16" y="68" width="382" height="0.0"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="26"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="o8G-Od-1s5">
<rect key="frame" x="16" y="69" width="382" height="0.0"/>
<rect key="frame" x="16" y="73" width="382" height="0.0"/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="8cS-Q3-g81" userLabel="Status Parent">
<rect key="frame" x="15" y="84" width="384" height="216"/>
<rect key="frame" x="15" y="88" width="384" height="216"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="D2w-ln-CB5">
<rect key="frame" x="0.0" y="0.0" width="384" height="216"/>
Expand All @@ -56,10 +55,10 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="F4s-4P-Fv2" customClass="HomeAdviceView" customModule="Kikurage" customModuleProvider="target">
<rect key="frame" x="15" y="420" width="384" height="357"/>
<rect key="frame" x="15" y="424" width="384" height="353"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ThT-WZ-a6t" userLabel="Value Parent">
<rect key="frame" x="15" y="315" width="384" height="100"/>
<rect key="frame" x="15" y="319" width="384" height="100"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="top" spacing="12" translatesAutoresizingMaskIntoConstraints="NO" id="lJ7-a1-55m">
<rect key="frame" x="89" y="0.0" width="60.5" height="78"/>
Expand Down Expand Up @@ -156,7 +155,7 @@
<constraint firstItem="9eI-cw-kb6" firstAttribute="top" secondItem="Y50-vB-neh" secondAttribute="bottom" constant="6.5" id="vFp-rY-an5"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="NqP-qu-naX" customClass="FooterButtonView" customModule="Kikurage" customModuleProvider="target">
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="NqP-qu-naX" customClass="KUIFooterButtonView" customModule="Kikurage" customModuleProvider="target">
<rect key="frame" x="15" y="792" width="384" height="50"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
Expand Down Expand Up @@ -231,7 +230,7 @@
</scene>
</scenes>
<resources>
<image name="line.horizontal.3" catalog="system" width="128" height="64"/>
<image name="line.horizontal.3" catalog="system" width="128" height="65"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ extension GraphBaseView {
switch graphDataType {
case .temperature:
let dataSet = LineChartDataSet(entries: entrys, label: "[℃]")
dataSet.colors = [.subColor]
dataSet.circleColors = [.subColor]
dataSet.colors = [R.color.subColor()!]
dataSet.circleColors = [R.color.subColor()!]
temperatureLineChartView.data = LineChartData(dataSet: dataSet)
temperatureLineChartView.xAxis.labelPosition = .bottom
temperatureLineChartView.leftAxis.addLimitLine(temperatureLimitLine)
temperatureLineChartView.xAxis.valueFormatter = chartViewHelper
case .humidity:
let dataSet = LineChartDataSet(entries: entrys, label: "[%]")
dataSet.colors = [.subColor]
dataSet.circleColors = [.subColor]
dataSet.colors = [R.color.subColor()!]
dataSet.circleColors = [R.color.subColor()!]
humidityLineChartView.data = LineChartData(dataSet: dataSet)
humidityLineChartView.xAxis.labelPosition = .bottom
humidityLineChartView.leftAxis.addLimitLine(humidityLimitLine)
Expand Down
Loading