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
36 changes: 36 additions & 0 deletions TeamMiniApp-API.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
8781411927FD11460095AECD /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8781411827FD11460095AECD /* Assets.xcassets */; };
8781411C27FD11460095AECD /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8781411A27FD11460095AECD /* LaunchScreen.storyboard */; };
8781412527FD1A910095AECD /* .swiftlint.yml in Resources */ = {isa = PBXBuildFile; fileRef = 8781412427FD1A910095AECD /* .swiftlint.yml */; };
9553D519280158F200B4C78F /* SelectNumberTecArticleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9553D518280158F200B4C78F /* SelectNumberTecArticleViewController.swift */; };
9553D51C2801597700B4C78F /* TecArticleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9553D51B2801597700B4C78F /* TecArticleViewController.swift */; };
9553D51E2801598C00B4C78F /* WebTecArticleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9553D51D2801598C00B4C78F /* WebTecArticleViewController.swift */; };
9553D52128015DAE00B4C78F /* TecArticleTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9553D51F28015DAE00B4C78F /* TecArticleTableViewCell.swift */; };
9553D52228015DAE00B4C78F /* TecArticleTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9553D52028015DAE00B4C78F /* TecArticleTableViewCell.xib */; };
9553D52428015E5700B4C78F /* GetArticle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9553D52328015E5700B4C78F /* GetArticle.swift */; };
9553D52628015E7B00B4C78F /* NewsArticle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9553D52528015E7B00B4C78F /* NewsArticle.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -27,6 +34,13 @@
8781411B27FD11460095AECD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
8781411D27FD11460095AECD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8781412427FD1A910095AECD /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .swiftlint.yml; sourceTree = "<group>"; };
9553D518280158F200B4C78F /* SelectNumberTecArticleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectNumberTecArticleViewController.swift; sourceTree = "<group>"; };
9553D51B2801597700B4C78F /* TecArticleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TecArticleViewController.swift; sourceTree = "<group>"; };
9553D51D2801598C00B4C78F /* WebTecArticleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebTecArticleViewController.swift; sourceTree = "<group>"; };
9553D51F28015DAE00B4C78F /* TecArticleTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TecArticleTableViewCell.swift; sourceTree = "<group>"; };
9553D52028015DAE00B4C78F /* TecArticleTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TecArticleTableViewCell.xib; sourceTree = "<group>"; };
9553D52328015E5700B4C78F /* GetArticle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetArticle.swift; sourceTree = "<group>"; };
9553D52528015E7B00B4C78F /* NewsArticle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewsArticle.swift; sourceTree = "<group>"; };
B171D68812E28A942DA80197 /* Pods-TeamMiniApp-API.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TeamMiniApp-API.debug.xcconfig"; path = "Target Support Files/Pods-TeamMiniApp-API/Pods-TeamMiniApp-API.debug.xcconfig"; sourceTree = "<group>"; };
F67185BABEF2E648D9E54220 /* Pods_TeamMiniApp_API.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TeamMiniApp_API.framework; sourceTree = BUILT_PRODUCTS_DIR; };
FBC26C711A97690244CDC229 /* Pods-TeamMiniApp-API.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TeamMiniApp-API.release.xcconfig"; path = "Target Support Files/Pods-TeamMiniApp-API/Pods-TeamMiniApp-API.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -73,6 +87,7 @@
8781410E27FD11460095AECD /* TeamMiniApp-API */ = {
isa = PBXGroup;
children = (
9553D51A2801596000B4C78F /* Tec */,
8781410F27FD11460095AECD /* AppDelegate.swift */,
8781411127FD11460095AECD /* SceneDelegate.swift */,
8781411327FD11460095AECD /* ViewController.swift */,
Expand All @@ -85,6 +100,20 @@
path = "TeamMiniApp-API";
sourceTree = "<group>";
};
9553D51A2801596000B4C78F /* Tec */ = {
isa = PBXGroup;
children = (
9553D518280158F200B4C78F /* SelectNumberTecArticleViewController.swift */,
9553D51B2801597700B4C78F /* TecArticleViewController.swift */,
9553D51D2801598C00B4C78F /* WebTecArticleViewController.swift */,
9553D51F28015DAE00B4C78F /* TecArticleTableViewCell.swift */,
9553D52028015DAE00B4C78F /* TecArticleTableViewCell.xib */,
9553D52328015E5700B4C78F /* GetArticle.swift */,
9553D52528015E7B00B4C78F /* NewsArticle.swift */,
);
path = Tec;
sourceTree = "<group>";
};
BCDCF2C3849305B3EDE8DD7A /* Pods */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -159,6 +188,7 @@
8781411C27FD11460095AECD /* LaunchScreen.storyboard in Resources */,
8781411927FD11460095AECD /* Assets.xcassets in Resources */,
8781411727FD11460095AECD /* Main.storyboard in Resources */,
9553D52228015DAE00B4C78F /* TecArticleTableViewCell.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -229,7 +259,13 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
9553D519280158F200B4C78F /* SelectNumberTecArticleViewController.swift in Sources */,
9553D51E2801598C00B4C78F /* WebTecArticleViewController.swift in Sources */,
8781411427FD11460095AECD /* ViewController.swift in Sources */,
9553D52128015DAE00B4C78F /* TecArticleTableViewCell.swift in Sources */,
9553D52628015E7B00B4C78F /* NewsArticle.swift in Sources */,
9553D51C2801597700B4C78F /* TecArticleViewController.swift in Sources */,
9553D52428015E5700B4C78F /* GetArticle.swift in Sources */,
8781411027FD11460095AECD /* AppDelegate.swift in Sources */,
8781411227FD11460095AECD /* SceneDelegate.swift in Sources */,
);
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "5BAB7DAE-E9E3-45E8-BE45-660263A6DE27"
type = "0"
version = "2.0">
</Bucket>
107 changes: 104 additions & 3 deletions TeamMiniApp-API/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,122 @@
</objects>
<point key="canvasLocation" x="1929" y="499"/>
</scene>
<!--View Controller-->
<!--Select Number Tec Article View Controller-->
<scene sceneID="l8K-Er-rva">
<objects>
<viewController id="ZLK-nh-pVs" sceneMemberID="viewController">
<viewController id="ZLK-nh-pVs" customClass="SelectNumberTecArticleViewController" customModule="TeamMiniApp_API" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="grH-ZW-PNE">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qdB-dc-E5P">
<rect key="frame" x="134" y="105" width="146" height="83"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<slider opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="25" minValue="0.0" maxValue="50" translatesAutoresizingMaskIntoConstraints="NO" id="K2P-1S-52P">
<rect key="frame" x="52" y="236" width="311" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<connections>
<action selector="tappedSlider:" destination="ZLK-nh-pVs" eventType="valueChanged" id="KBF-0h-cPC"/>
</connections>
</slider>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="0" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MfA-DL-eHA">
<rect key="frame" x="54" y="200" width="11" 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="50" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="G4G-aX-KxM">
<rect key="frame" x="342" y="193" width="30" height="35"/>
<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="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="u8N-dt-vMq">
<rect key="frame" x="125" y="408" width="155" height="80"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="記事の一覧を表示"/>
<connections>
<action selector="tappedTecArticleViewButton:" destination="ZLK-nh-pVs" eventType="touchUpInside" id="Wag-C5-faL"/>
</connections>
</button>
</subviews>
<viewLayoutGuide key="safeArea" id="TAt-c6-caC"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
<navigationItem key="navigationItem" id="UlK-y3-Js0"/>
<connections>
<outlet property="numberTecArticle" destination="qdB-dc-E5P" id="81l-Fu-qwR"/>
<outlet property="slider" destination="K2P-1S-52P" id="Zx2-rT-YKK"/>
<segue destination="rKm-Yr-Aeu" kind="show" identifier="tecArticleViewControllerSegue" id="qZS-rC-JpX"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="AIm-We-oRW" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1930" y="-324"/>
<point key="canvasLocation" x="1928.985507246377" y="-324.10714285714283"/>
</scene>
<!--Tec Article View Controller-->
<scene sceneID="Y7O-xv-cMD">
<objects>
<viewController id="rKm-Yr-Aeu" customClass="TecArticleViewController" customModule="TeamMiniApp_API" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="d4c-g1-z2g">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="osl-GS-nWp">
<rect key="frame" x="0.0" y="88" width="414" height="808"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</tableView>
</subviews>
<viewLayoutGuide key="safeArea" id="ncw-9I-va5"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
<navigationItem key="navigationItem" id="2qd-c2-Ylz"/>
<connections>
<outlet property="tableView" destination="osl-GS-nWp" id="Lnn-vG-p4S"/>
<segue destination="1WD-us-fdX" kind="show" identifier="WebTecArticleViewControllerSegue" id="JZW-49-yaF"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="lQv-IB-miw" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2882.608695652174" y="-324.10714285714283"/>
</scene>
<!--Web Tec Article View Controller-->
<scene sceneID="D7F-hQ-Z6R">
<objects>
<viewController id="1WD-us-fdX" customClass="WebTecArticleViewController" customModule="TeamMiniApp_API" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="bak-0z-4RW">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<wkWebView contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9k7-i0-Rmd">
<rect key="frame" x="0.0" y="88" width="414" height="808"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.36078431370000003" green="0.38823529410000002" blue="0.4039215686" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<wkWebViewConfiguration key="configuration">
<audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
<wkPreferences key="preferences"/>
</wkWebViewConfiguration>
</wkWebView>
</subviews>
<viewLayoutGuide key="safeArea" id="nvF-BM-9kp"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
<navigationItem key="navigationItem" id="p4H-Fq-nKE"/>
<connections>
<outlet property="webView" destination="9k7-i0-Rmd" id="b6x-sT-rMa"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="C80-y8-hJR" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="3860.8695652173915" y="-324.10714285714283"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="fHI-Dy-uNx">
Expand Down
35 changes: 35 additions & 0 deletions TeamMiniApp-API/Tec/GetArticle.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// GetArticleData.swift
// TeamMiniApp-API
//
// Created by 近藤米功 on 2022/04/09.
//
import Foundation
import Alamofire
protocol GetArticleDelegate: AnyObject{
func catchArticleData(articles: Article)
}

class GetArticle{
weak var delegate: GetArticleDelegate?
func request(size: Int){
let url = "https://newsapi.org/v2/top-headlines?country=jp&pageSize=\(size)&category=technology&apiKey=2dadbe9531074cfe86934358180c7e24"
// エンコードしないと、category名が日本語の時に対応できない
let encorderUrlString:String = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
AF.request(encorderUrlString, method: .get, parameters: nil, encoding: JSONEncoding.default).responseJSON {
response in
switch response.result{
case .success:
do{
let articles = try JSONDecoder().decode(Article.self, from: response.data!)
self.delegate?.catchArticleData(articles: articles)
}
catch{
print("取得失敗")
}
case .failure(_):
print("switchFail")
}
}
}
}
16 changes: 16 additions & 0 deletions TeamMiniApp-API/Tec/NewsArticle.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// NewsArticle.swift
// TeamMiniApp-API
//
// Created by 近藤米功 on 2022/04/09.
//

import Foundation
struct Article: Codable {
var articles: [ArticleInfo]
}
struct ArticleInfo: Codable {
let publishedAt: String?
let title: String?
let url: String?
}
30 changes: 30 additions & 0 deletions TeamMiniApp-API/Tec/SelectNumberTecArticleViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// SelectNumberTecArticeViewController.swift
// TeamMiniApp-API
//
// Created by 近藤米功 on 2022/04/09.
//

import UIKit

class SelectNumberTecArticleViewController: UIViewController {
@IBOutlet private weak var slider: UISlider!
@IBOutlet private weak var numberTecArticle: UILabel!

@IBAction private func tappedSlider(_ sender: Any) {
numberTecArticle.text = String(Int(slider.value))
}

@IBAction private func tappedTecArticleViewButton(_ sender: Any) {
performSegue(withIdentifier: "tecArticleViewControllerSegue", sender: nil)
}


override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// 画面遷移時にスライダーの値(記事数)を渡す
if segue.identifier == "tecArticleViewControllerSegue" {
let tecArticleVC = segue.destination as! TecArticleViewController
tecArticleVC.catchNumberTecArticle = Int(slider.value)
}
}
}
Loading