Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions sunset.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
32CDE1041D9513EA00A57C02 /* SwiftyJSON.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 32CDE1011D9513EA00A57C02 /* SwiftyJSON.framework */; };
32D0D7E11D9B94E800FF7F33 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 322AF8F81D9B90F100E7034F /* Nimble.framework */; };
32D0D7E81D9CBFEB00FF7F33 /* WebView.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 32D0D7E71D9CBFEB00FF7F33 /* WebView.storyboard */; };
32D0D7EA1D9CC37D00FF7F33 /* webviewUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32D0D7E91D9CC37D00FF7F33 /* webviewUITests.swift */; };
32D0D7EC1D9CDA6500FF7F33 /* WebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32D0D7EB1D9CDA6500FF7F33 /* WebViewController.swift */; };
332B1A271D815670007064CF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 332B1A261D815670007064CF /* AppDelegate.swift */; };
332B1A2E1D815670007064CF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 332B1A2D1D815670007064CF /* Assets.xcassets */; };
Expand Down Expand Up @@ -104,7 +103,6 @@
32CDE1011D9513EA00A57C02 /* SwiftyJSON.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftyJSON.framework; path = Carthage/Build/iOS/SwiftyJSON.framework; sourceTree = "<group>"; };
32D0D7E41D9BA7AE00FF7F33 /* OHHTTPStubs.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OHHTTPStubs.framework; path = Carthage/Build/iOS/OHHTTPStubs.framework; sourceTree = "<group>"; };
32D0D7E71D9CBFEB00FF7F33 /* WebView.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = WebView.storyboard; sourceTree = "<group>"; };
32D0D7E91D9CC37D00FF7F33 /* webviewUITests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = webviewUITests.swift; sourceTree = "<group>"; };
32D0D7EB1D9CDA6500FF7F33 /* WebViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebViewController.swift; sourceTree = "<group>"; };
332B1A231D815670007064CF /* sunset.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = sunset.app; sourceTree = BUILT_PRODUCTS_DIR; };
332B1A261D815670007064CF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -268,7 +266,6 @@
children = (
332B1A461D815670007064CF /* sunsetUITests.swift */,
332B1A481D815670007064CF /* Info.plist */,
32D0D7E91D9CC37D00FF7F33 /* webviewUITests.swift */,
3106785A1E57542C00C829E6 /* settingsUITests.swift */,
);
path = sunsetUITests;
Expand Down Expand Up @@ -699,7 +696,6 @@
files = (
3106785B1E57542C00C829E6 /* settingsUITests.swift in Sources */,
332B1A471D815670007064CF /* sunsetUITests.swift in Sources */,
32D0D7EA1D9CC37D00FF7F33 /* webviewUITests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
12 changes: 4 additions & 8 deletions sunset/Classes/Controllers/CalendarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CalendarViewController: UIViewController, UICollectionViewDataSource, UICo
var prevDay: String!
var prevIndexPath: IndexPath?
let appDelegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
let TapCalendarCellNotification = Notification.Name("TapCelandarCell")
let TapCalendarCellNotification: Notification.Name = Notification.Name("TapCelandarCell")
let realm: Realm = try! Realm()
var notificationToken: NotificationToken? = nil

Expand Down Expand Up @@ -41,15 +41,15 @@ class CalendarViewController: UIViewController, UICollectionViewDataSource, UICo
override func viewDidLoad() {
super.viewDidLoad()

let tweetModel = self.realm.objects(Tweet.self)
let tweetModel: Results<Tweet> = self.realm.objects(Tweet.self)

calendarCollectionView.delegate = self
calendarCollectionView.dataSource = self
calendarCollectionView.backgroundColor = UIColor.clear
self.view.backgroundColor = UIColor.clear

let TapPrevBtnNotification = Notification.Name("TapPrevBtn")
let TapNextBtnNotification = Notification.Name("TapNextBtn")
let TapPrevBtnNotification: Notification.Name = Notification.Name("TapPrevBtn")
let TapNextBtnNotification: Notification.Name = Notification.Name("TapNextBtn")
NotificationCenter.default.addObserver(self, selector: #selector(self.updatePrevView(_:)), name: TapPrevBtnNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.updateNextView(_:)), name: TapNextBtnNotification, object: nil)

Expand All @@ -66,10 +66,6 @@ class CalendarViewController: UIViewController, UICollectionViewDataSource, UICo
super.didReceiveMemoryWarning()
}

func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return dateManager.daysAcquisition() //ここは月によって異なる
}
Expand Down
4 changes: 0 additions & 4 deletions sunset/Classes/Controllers/DaysViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ class DaysViewController: UIViewController, UICollectionViewDataSource, UICollec
super.didReceiveMemoryWarning()
}

func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 7
}
Expand Down
6 changes: 3 additions & 3 deletions sunset/Classes/Controllers/MicropostViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class MicropostViewController: UITableViewController {

var tweets: [Tweet] = []
let appDelegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
let sessionStore = Twitter.sharedInstance().sessionStore
let sessionStore: TWTRSessionStore = Twitter.sharedInstance().sessionStore
let tweetManager: TweetManager = TweetManager()

override func viewDidLoad() {
Expand All @@ -21,7 +21,7 @@ class MicropostViewController: UITableViewController {
appDelegate.targetDate = initialDate()
}

let TapCalendarCellNotification = Notification.Name("TapCelandarCell")
let TapCalendarCellNotification: Notification.Name = Notification.Name("TapCelandarCell")
NotificationCenter.default.addObserver(self, selector: #selector(self.updateView(_:)), name: TapCalendarCellNotification, object: nil)
self.tableView.reloadData()
}
Expand All @@ -35,7 +35,7 @@ class MicropostViewController: UITableViewController {
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCell(withIdentifier: "micropostCell", for: indexPath)
let cell: UITableViewCell = self.tableView.dequeueReusableCell(withIdentifier: "micropostCell", for: indexPath)
if (self.sessionStore.session()?.userID != nil) {
updateCell(cell, indexPath: indexPath)
}
Expand Down
24 changes: 12 additions & 12 deletions sunset/Classes/Controllers/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ extension UIColor {

class SettingsViewController: UITableViewController {

let settingsText = ["アカウント", "Twitter"]
let settingsText: [String] = ["アカウント", "Twitter"]
// 設定項目の見出しセルの index
let optionIndex = [0, 2]
let sessionStore = Twitter.sharedInstance().sessionStore
let optionIndex: [Int] = [0, 2]
let sessionStore: TWTRSessionStore = Twitter.sharedInstance().sessionStore
let appDelegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
let tweetManager: TweetManager = TweetManager()

Expand All @@ -36,18 +36,18 @@ class SettingsViewController: UITableViewController {
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// 設定タイトル
if (indexPath.row == 0) {
let cell = self.tableView.dequeueReusableCell(withIdentifier: "settingsTitlesViewCell", for: indexPath) as! SettingsTitlesViewCell
let cell: SettingsTitlesViewCell = self.tableView.dequeueReusableCell(withIdentifier: "settingsTitlesViewCell", for: indexPath) as! SettingsTitlesViewCell
cell.backgroundColor = UIColor(red: 255 / 255, green: 250 / 255, blue: 250 / 255, alpha: 1.0)
cell.settingsTitleLabel.font = UIFont.fontAwesome(ofSize: 16)
cell.settingsTitleLabel.text = String.fontAwesomeIcon(name: .cog)
return cell
// アカウント連携セル
} else if (indexPath.row < 3) {
let cell = insertAccountContents(indexPath: indexPath)
let cell: UITableViewCell = insertAccountContents(indexPath: indexPath)
return cell
// その他
} else {
let cell = insertThemeContents(indexPath: indexPath)
let cell: UITableViewCell = insertThemeContents(indexPath: indexPath)
return cell
}
}
Expand Down Expand Up @@ -75,12 +75,12 @@ class SettingsViewController: UITableViewController {
// アカウント連携セル用
private func insertAccountContents(indexPath: IndexPath) -> UITableViewCell {
if (self.optionIndex.contains(indexPath.row - 1)) {
let cell = self.tableView.dequeueReusableCell(withIdentifier: "settingsTitlesViewCell", for: indexPath) as! SettingsTitlesViewCell
let cell: SettingsTitlesViewCell = self.tableView.dequeueReusableCell(withIdentifier: "settingsTitlesViewCell", for: indexPath) as! SettingsTitlesViewCell
cell.settingsTitleLabel.text = settingsText[indexPath.row - 1]
cell.settingsTitleLabel.font = UIFont(name: "HirakakuProN-W6", size: 12)
return cell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: "accountsTableCell", for: indexPath) as! AccountsTableViewCell
let cell: AccountsTableViewCell = tableView.dequeueReusableCell(withIdentifier: "accountsTableCell", for: indexPath) as! AccountsTableViewCell
// ログインしている状態
if (self.sessionStore.session()?.userID != nil) {
// 連携しているアカウントには チェックマーク をつける
Expand All @@ -104,12 +104,12 @@ class SettingsViewController: UITableViewController {
// テーマ選択セル用
private func insertThemeContents(indexPath: IndexPath) -> UITableViewCell {
if (self.optionIndex.contains(indexPath.row - 1)) {
let cell = self.tableView.dequeueReusableCell(withIdentifier: "settingsTitlesViewCell", for: indexPath) as! SettingsTitlesViewCell
let cell: SettingsTitlesViewCell = self.tableView.dequeueReusableCell(withIdentifier: "settingsTitlesViewCell", for: indexPath) as! SettingsTitlesViewCell
cell.settingsTitleLabel.text = settingsText[indexPath.row - 1]
cell.settingsTitleLabel.font = UIFont(name: "HirakakuProN-W6", size: 12)
return cell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: "accountsTableCell", for: indexPath) as! AccountsTableViewCell
let cell: AccountsTableViewCell = tableView.dequeueReusableCell(withIdentifier: "accountsTableCell", for: indexPath) as! AccountsTableViewCell
cell.loginStatus.text = ""
cell.accountInfo.text = settingsText[indexPath.row - 1]
cell.accountInfo.font = UIFont(name: "HirakakuProN-W3", size: 11)
Expand All @@ -122,9 +122,9 @@ class SettingsViewController: UITableViewController {

let defaultAction: UIAlertAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler:{
(action: UIAlertAction!) -> Void in
let sessionStore = Twitter.sharedInstance().sessionStore
let sessionStore: TWTRSessionStore = Twitter.sharedInstance().sessionStore

if let userId = sessionStore.session()?.userID {
if let userId: String = sessionStore.session()?.userID {
self.tweetManager.deleteAll()
sessionStore.logOutUserID(userId)
}
Expand Down
22 changes: 10 additions & 12 deletions sunset/Classes/Controllers/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ class ViewController: UIViewController {
@IBOutlet weak var headerPrevBtn: UIButton!
@IBOutlet weak var headerNextBtn: UIButton!
let appDelegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
let formatter = DateFormatter()
let TapPrevBtnNotification = Notification.Name("TapPrevBtn")
let TapNextBtnNotification = Notification.Name("TapNextBtn")
let formatter: DateFormatter = DateFormatter()
let TapPrevBtnNotification: Notification.Name = Notification.Name("TapPrevBtn")
let TapNextBtnNotification: Notification.Name = Notification.Name("TapNextBtn")
@IBInspectable var top: UIColor = UIColor.darkOrange()
@IBInspectable var bottom: UIColor = UIColor.lightIndigo()


override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let formatter = DateFormatter()
// 初期値 (今日の日付を元に、navigationBarのタイトルを決める)
formatter.dateFormat = "MMM yyyy"
self.title = formatter.string(from: Date())
Expand Down Expand Up @@ -51,27 +49,27 @@ class ViewController: UIViewController {
}

@IBAction func tappedPrevMonthBtn(_ sender: UIButton) {
let thisDate = generateTargetDate()
let thisDate: String = generateTargetDate()
let prevDate: Date = formatter.date(from: thisDate)!.monthAgoDate()
appDelegate.targetDate = formatter.string(from: prevDate)
NotificationCenter.default.post(name: TapPrevBtnNotification, object: nil)
}

@IBAction func tappedNextMonthBtn(_ sender: UIButton) {
let thisDate = generateTargetDate()
let thisDate: String = generateTargetDate()
let nextDate: Date = formatter.date(from: thisDate)!.monthLaterDate()
appDelegate.targetDate = formatter.string(from: nextDate)
NotificationCenter.default.post(name: TapNextBtnNotification, object: nil)
}

private func generateTargetDate() -> String {
formatter.dateFormat = "yyyy-MM-dd"
let thisDate = appDelegate.targetDate
let year:String = (thisDate?.components(separatedBy: "-")[0])!
let month:String = (thisDate?.components(separatedBy: "-")[1])!
let day:String = (thisDate?.components(separatedBy: "-")[2])!
let thisDate: String? = appDelegate.targetDate
let year: String = (thisDate?.components(separatedBy: "-")[0])!
let month: String = (thisDate?.components(separatedBy: "-")[1])!
let day: String = (thisDate?.components(separatedBy: "-")[2])!

let thisDateString = year + "-" + month + "-" + day
let thisDateString: String = year + "-" + month + "-" + day
return thisDateString
}

Expand Down
10 changes: 5 additions & 5 deletions sunset/Classes/Controllers/WebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ class WebViewController: UIViewController, UIWebViewDelegate {

self.webView.delegate = self

let appDelegate:AppDelegate = UIApplication.shared.delegate as! AppDelegate
let appDelegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate

let tweetId = appDelegate.tweetID
let userId = appDelegate.userID
let tweetId: String? = appDelegate.tweetID
let userId: String? = appDelegate.userID

let baseUrl: String = "https://twitter.com/"

let initUrl = URL(string: baseUrl + userId! + "/status/" + tweetId!)
let initUrl: URL? = URL(string: baseUrl + userId! + "/status/" + tweetId!)

let request = URLRequest(url: initUrl!)
let request: URLRequest = URLRequest(url: initUrl!)
self.webView.loadRequest(request)
}

Expand Down
8 changes: 0 additions & 8 deletions sunset/Classes/Helpers/GradationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,4 @@ class GradationView {
gradientLayer.frame = view.bounds
view.layer.insertSublayer(gradientLayer, at: 0)
}

func addGradation(view: UITableView) {
addGradation(view: view as UIView)
}

func addGradation(view: UICollectionView) {
addGradation(view: view as UIView)
}
}
10 changes: 5 additions & 5 deletions sunset/Classes/Helpers/TwitterAPIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class TwitterAPIClient {
let realm: Realm = try! Realm()

func savePosts() {
let formatter = DateFormatter()
let formatter: DateFormatter = DateFormatter()
formatter.locale = Locale(identifier: "ja_JP")
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"

Expand All @@ -31,15 +31,15 @@ class TwitterAPIClient {
let client = TWTRAPIClient(userID: Twitter.sharedInstance().sessionStore.session()?.userID)

var clientError: NSError?
let endpoint = "https://api.twitter.com/1.1/statuses/user_timeline.json"
let params = ["include_rts": "false", "trim_user": "false", "count": "100"]
let request = client.urlRequest(withMethod: "GET", url: endpoint, parameters: params, error: &clientError)
let endpoint: String = "https://api.twitter.com/1.1/statuses/user_timeline.json"
let params: [AnyHashable: Any] = ["include_rts": "false", "trim_user": "false", "count": "100"]
let request: URLRequest = client.urlRequest(withMethod: "GET", url: endpoint, parameters: params, error: &clientError)

client.sendTwitterRequest(request, completion: {
response, data, err in
if (err == nil) {
let json: AnyObject? = try! JSONSerialization.jsonObject(with: data!) as AnyObject?
if let jsonArray = json as? NSArray {
if let jsonArray: NSArray = json as? NSArray {
tweets(TWTRTweet.tweets(withJSONArray: jsonArray as [AnyObject]) as! [TWTRTweet])
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion sunset/Classes/Models/TweetManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TweetManager {
self.realm.deleteAll()
}
} catch {
let error = error as NSError
let error: NSError = error as NSError
print("error: \(error), \(error.userInfo)")
}

Expand Down
2 changes: 1 addition & 1 deletion sunset/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.1</string>
<string>1.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
Loading