Skip to content

Instantly share code, notes, and snippets.

View fumiyasac's full-sized avatar
🎯
Focusing

Fumiya Sakai fumiyasac

🎯
Focusing
View GitHub Profile
@fumiyasac
fumiyasac / CalculateCalendarLogic.swift
Last active January 19, 2018 12:51
個人開発及び実務でユニットテストに助けられたと個人的に感じた例の紹介 ref: https://qiita.com/fumiyasac@github/items/19c525116f1b585bb43f
public struct CalculateCalendarLogic {
/**
*
* 祝日になる日を判定する
* (引数) year: Int, month: Int, day: Int, weekdayIndex: Int
* weekdayIndexはWeekdayのenumに該当する値(0...6)が入る
* ※1. カレンダーロジックの参考:http://p-ho.net/index.php?page=2s2
* ※2. 書き方(タプル)の参考:http://blog.kitoko552.com/entry/2015/06/17/213553
* ※3. [Swift] 関数における引数/戻り値とタプルの関係:http://dev.classmethod.jp/smartphone/swift-function-tupsle/
@fumiyasac
fumiyasac / ArticleViewController.swift
Last active December 11, 2017 11:46
Swift4にも対応したUI系のライブラリを活用して面白い動きを入れてみたサンプル実装まとめ ref: https://qiita.com/fumiyasac@github/items/48617348ef7f18494d38
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if let navigationController = navigationController as? ScrollingNavigationController {
navigationController.followScrollView(articleTableView, delay: 44.0)
//MEMO: ScrollingNavigationControllerDelegateを利用する際に必要な宣言
//navigationController.scrollingNavbarDelegate = self
}
}
@fumiyasac
fumiyasac / FlipDismissCustomTransition.swift
Last active November 21, 2018 08:14
できるだけUI系のライブラリを用いないアニメーションを盛り込んだサンプル実装まとめ(後編) ref: https://qiita.com/fumiyasac@github/items/b694f9859cbb61c95c1a
import Foundation
import UIKit
class FlipDismissCustomTransition: NSObject {
//トランジション(実行)の秒数
fileprivate let duration: TimeInterval = 0.72
//ディレイ(遅延)の秒数
fileprivate let delay: TimeInterval = 0.00
@fumiyasac
fumiyasac / Article.swift
Last active November 21, 2018 08:04
できるだけUI系のライブラリを用いないアニメーションを盛り込んだサンプル実装まとめ(前編) ref: https://qiita.com/fumiyasac@github/items/d1b56ffc6d7d46c0a616
import Foundation
import UIKit
import SwiftyJSON
struct Article {
//メンバ変数(取得したJSONレスポンスのKeyに対応する値が入る)
let id: Int
let thumbnailUrl: String
let title: String
@fumiyasac
fumiyasac / App.js
Last active September 19, 2017 15:45
NativeBaseをはじめとするUI関連のライブラリを活用してReactNativeでUIサンプルを作成した際の詳細解説 ref: http://qiita.com/fumiyasac@github/items/12707f93f5c96fa3fc3f
/**
* アプリコンテンツ用のコンポーネント
*/
import React, { Component } from 'react';
//react-native-router-fluxのインポート宣言(Actionを使用)
import { Router, Scene } from 'react-native-router-flux';
//自作コンポーネント
@fumiyasac
fumiyasac / AlbumList.js
Last active April 2, 2017 09:55
ReactNative事始めから簡単なサンプルを読み解くまでの実践記録ノート ref: http://qiita.com/fumiyasac@github/items/71b8ff88d96289d43593
/**
* アルバム一覧用のコンポーネント
*/
import React, { Component } from 'react';
import { ScrollView } from 'react-native';
//HTTP通信用のライブラリ'axios'のインポート宣言
import axios from 'axios';
//アルバム詳細用の共通コンポーネントのインポート宣言
@fumiyasac
fumiyasac / AddController.swift
Last active October 5, 2017 07:07
ジェスチャーやカスタムトランジションを利用して入力時やコンテンツ表示時に一工夫を加えたUIの実装ポイントまとめ ref: http://qiita.com/fumiyasac@github/items/6c4c2b909a821932be04
//レシピを登録する時のアクション
@IBAction func saveRecipeAction(_ sender: UIButton) {
//キーボードを閉じる
view.endEditing(true)
//ボタンを非活性状態にする
closeButton.isEnabled = false
saveButton.isEnabled = false
@fumiyasac
fumiyasac / Constants.swift
Last active April 12, 2019 06:39
RxSwiftでの実装練習の記録ノート(後編:DriverパターンとAPIへの通信を伴うMVVM構成のサンプル例) ref: https://qiita.com/fumiyasac@github/items/da762ea512484a8291a3
enum APIKey: String {
case foresquare_clientid = "自分のクライアントID"
case foresquare_clientsecret = "自分のシークレット"
}
@fumiyasac
fumiyasac / Ramen.swift
Last active March 13, 2019 03:21
RxSwiftでの実装練習の記録ノート(前編:Observerパターンの例とUITableViewの例) ref: https://qiita.com/fumiyasac@github/items/90d1ebaa0cd8c4558d96
import UIKit
import RxDataSources
//ラーメンデータ定義用の構造体(Model層)
struct Ramen {
//取得データに関する定義
let name: String
let taste: String
let imageId: String
@fumiyasac
fumiyasac / MainContentsCell.swift
Last active December 20, 2016 16:48
FacebookやTwitterのアプリで気になった表現を自分なりにトレースした際の実装ポイントまとめ(タイルレイアウトがサムネイル画像の枚数に応じて変わる表現) ref: http://qiita.com/fumiyasac@github/items/3be1344255b3ebb9f416
//「もっと他の画像を見る」ボタンのアクション
@IBAction func moreImageAction(_ sender: UIButton) {
transitionClosure!(nil)
}
//サムネイル画像のTapGesture発動時に実行されるメソッド
func tapGesture(sender: UITapGestureRecognizer) {
let targetNumber: Int = (sender.view?.tag)!
transitionClosure!(targetNumber)
}