Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

“misson2と3を完成” #102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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: 4 additions & 0 deletions icchii/iOS-client/My1DayApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
3ABA190A1B062C5B00C21087 /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3ABA19091B062C5B00C21087 /* Message.swift */; };
3ABA190C1B0633E800C21087 /* ImageHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3ABA190B1B0633E800C21087 /* ImageHelper.swift */; };
3AF957B81B05067F00106729 /* logo.png in Resources */ = {isa = PBXBuildFile; fileRef = 3AF957B71B05067F00106729 /* logo.png */; };
C3B2A8D11B11BF5B00E46DDF /* A.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = C3B2A8D01B11BF5B00E46DDF /* A.jpeg */; };
CE8066ED1ADDF6E3003A2D22 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE8066EC1ADDF6E3003A2D22 /* AppDelegate.swift */; };
CE8066F21ADDF6E3003A2D22 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CE8066F01ADDF6E3003A2D22 /* Main.storyboard */; };
CE8066F41ADDF6E3003A2D22 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CE8066F31ADDF6E3003A2D22 /* Images.xcassets */; };
Expand Down Expand Up @@ -52,6 +53,7 @@
3ABA19091B062C5B00C21087 /* Message.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Message.swift; sourceTree = "<group>"; };
3ABA190B1B0633E800C21087 /* ImageHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageHelper.swift; sourceTree = "<group>"; };
3AF957B71B05067F00106729 /* logo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = logo.png; sourceTree = "<group>"; };
C3B2A8D01B11BF5B00E46DDF /* A.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = A.jpeg; sourceTree = "<group>"; };
CE8066E71ADDF6E3003A2D22 /* My1DayApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = My1DayApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
CE8066EB1ADDF6E3003A2D22 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
CE8066EC1ADDF6E3003A2D22 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -143,6 +145,7 @@
isa = PBXGroup;
children = (
3ABA190B1B0633E800C21087 /* ImageHelper.swift */,
C3B2A8D01B11BF5B00E46DDF /* A.jpeg */,
3AF957B71B05067F00106729 /* logo.png */,
CE8066EB1ADDF6E3003A2D22 /* Info.plist */,
);
Expand Down Expand Up @@ -250,6 +253,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C3B2A8D11B11BF5B00E46DDF /* A.jpeg in Resources */,
3AF957B81B05067F00106729 /* logo.png in Resources */,
CE8066F21ADDF6E3003A2D22 /* Main.storyboard in Resources */,
CE8066F71ADDF6E3003A2D22 /* LaunchScreen.xib in Resources */,
Expand Down
Binary file added icchii/iOS-client/My1DayApp/A.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 17 additions & 3 deletions icchii/iOS-client/My1DayApp/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@
<rect key="frame" x="5" y="5" width="60" height="60"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="メッセージ" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="RPy-Rd-KYT">
<rect key="frame" x="78" y="13" width="234" height="21"/>
<rect key="frame" x="78" y="25" width="234" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Oxp-Sf-Gmd">
<rect key="frame" x="78" y="40" width="234" height="21"/>
<rect key="frame" x="78" y="45" width="234" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="S2m-zh-HQR">
<rect key="frame" x="78" y="5" width="234" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
Expand All @@ -39,6 +45,7 @@
<outlet property="dateLabel" destination="Oxp-Sf-Gmd" id="Zdw-aS-xqF"/>
<outlet property="iconImageView" destination="rB6-1N-vrf" id="qKn-zx-yfW"/>
<outlet property="messageLabel" destination="RPy-Rd-KYT" id="6X3-KT-Lfn"/>
<outlet property="userNameLabel" destination="S2m-zh-HQR" id="TQC-g2-Yeo"/>
</connections>
</tableViewCell>
</prototypes>
Expand Down Expand Up @@ -78,14 +85,20 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="200"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Lhg-Dc-uxP">
<rect key="frame" x="74" y="67" width="246" height="128"/>
<rect key="frame" x="74" y="125" width="246" height="68"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="logo.png" translatesAutoresizingMaskIntoConstraints="NO" id="71b-O0-MO6">
<rect key="frame" x="3" y="67" width="63" height="63"/>
</imageView>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="OLY-dj-Oen">
<rect key="frame" x="74" y="72" width="240" height="40"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
Expand Down Expand Up @@ -127,6 +140,7 @@
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
<connections>
<outlet property="messageTextView" destination="Lhg-Dc-uxP" id="Y5X-Cg-E1p"/>
<outlet property="userNameTextView" destination="OLY-dj-Oen" id="0VF-yP-Ywg"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="P5w-qQ-jfU" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down
5 changes: 4 additions & 1 deletion icchii/iOS-client/My1DayApp/Message.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@ class Message {
let icon: UIImage?
// Mission1-1. created_at 用のインスタンス変数を追加
let date: String!
let userName: String!
init?(dictionary: [String: AnyObject]) {
// Mission1-1 Dictionary から key:created_at の値を取得
if let body: String = dictionary["body"] as? String, let icon: String = dictionary["icon"] as? String, let date: String = dictionary["created_at"] as? String{
if let body: String = dictionary["body"] as? String, let icon: String = dictionary["icon"] as? String, let date: String = dictionary["created_at"] as? String, let userName: String = dictionary["username"] as? String{
self.body = body
self.icon = ImageHelper.imageWithBase64EncodedString(icon)
// Mission1-1 Dictionary から取得した値を created_at 用のインスタンス変数に追加
self.date = date
self.userName = userName
} else {
self.body = nil
self.icon = nil
// Mission1-1 インスタンス変数を nil で初期化
self.date = nil
self.userName = nil
return nil
}
}
Expand Down
10 changes: 9 additions & 1 deletion icchii/iOS-client/My1DayApp/MessageTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,26 @@ class MessageTableViewCell: UITableViewCell {
@IBOutlet weak private var messageLabel: UILabel!
// Mission1-1 UILabel のインスタンス変数を追加
@IBOutlet weak var dateLabel: UILabel!
@IBOutlet weak var userNameLabel: UILabel!

override func prepareForReuse() {
self.iconImageView.image = nil
self.messageLabel.text = nil
// Mission1-1 UILabel のインスタンス変数を初期化
self.dateLabel.text = nil
self.userNameLabel.text = nil
}

func setupComponentsWithMessage(message: Message) {
self.iconImageView.image = message.icon
if message.body == "daikichi" {
self.iconImageView.image = UIImage(named:"A.jpeg")
println("きてる")
} else{
self.iconImageView.image = message.icon
}
self.messageLabel.text = message.body
// Mission1-1 UILabel のインスタンス変数に created_at の値を代入
self.dateLabel.text = message.date
self.userNameLabel.text = message.userName
}
}
4 changes: 3 additions & 1 deletion icchii/iOS-client/My1DayApp/PostViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class PostViewController: UIViewController {
@IBOutlet weak private var messageTextView: UITextView!
weak var delegate: PostViewControllerDelagate?
// Mission1-2 Storyboard から UITextField のインスタンス変数を追加
@IBOutlet weak var userNameTextView: UITextView!

override func viewDidLoad() {
super.viewDidLoad()
Expand All @@ -34,9 +35,10 @@ class PostViewController: UIViewController {

let message: String = self.messageTextView.text ?? ""
// Mission1-2 UITextField のインスタンス変数から値を取得
let userName: String = self.userNameTextView.text ?? ""

// Mission1-2 posetMessage の第2引数に 任意の値を渡す
APIRequest.postMessage(message, username: "名前はまだない") {
APIRequest.postMessage(message, username: userName) {
[weak self] (data, response, error) -> Void in

self?.delegate?.postViewController(self!, didTouchUpCloseButton: sender)
Expand Down
43 changes: 42 additions & 1 deletion icchii/web-server/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,48 @@
$username = isset($data['username']) ? $data['username'] : '';
$body = isset($data['body']) ? $data['body'] : '';

$createdMessage = $app->createMessage($username, $body, base64_encode(file_get_contents($app['icon_image_path'])));
if(strstr($body, 'uranai')){

$i = rand(0,2);
if($i == 0){
$createdMessage = $app->createMessage($username, "daikichi", base64_encode(file_get_contents($app['icon_image_path'])));
}else if($i == 1){
$createdMessage = $app->createMessage($username, "kichi", base64_encode(file_get_contents($app['icon_image_path'])));
}else if($i == 2){
$createdMessage = $app->createMessage($username, "kyou", base64_encode(file_get_contents($app['icon_image_path'])));
}
}else if(strstr($body, 'sum')){
$pieces = explode(" ", $body);
$count = $pieces[1];
for($i = 2; $i < count($pieces) ; $i++){
$count = $count + $pieces[$i];
}
$createdMessage = $app->createMessage("Cal", $count, base64_encode(file_get_contents($app['icon_image_path'])));

}else if(strstr($body, 'sub')){
$pieces = explode(" ", $body);
$count = $pieces[1];
for($i = 2 ; $i < count($pieces) ; $i++){
$count = $count - $pieces[$i];
}
$createdMessage = $app->createMessage("Cal", $count, base64_encode(file_get_contents($app['icon_image_path'])));
}else if(strstr($body, 'dev')){
$pieces = explode(" ", $body);
$count = $pieces[1];
for($i = 2 ; $i < count($pieces) ; $i++){
$count = $count / $pieces[$i];
}
$createdMessage = $app->createMessage("Cal", $count, base64_encode(file_get_contents($app['icon_image_path'])));
}else if(strstr($body, 'mul')){
$pieces = explode(" ", $body);
$count = $pieces[1];
for($i = 2 ; $i < count($pieces) ; $i++){
$count = $count * $pieces[$i];
}
$createdMessage = $app->createMessage("Cal", $count, base64_encode(file_get_contents($app['icon_image_path'])));
}else{
$createdMessage = $app->createMessage($username, $body, base64_encode(file_get_contents($app['icon_image_path'])));
}

return $app->json($createdMessage);
});
Expand Down
Loading