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

signup画面の作成 #50

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
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: 3 additions & 1 deletion portfolio-ios-swiftui/.swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ disabled_rules:
- force_cast
# closureが返す値を明示しておきたい場合があるため
- unused_closure_parameter
# パラメータの個数制限を解除
- function_parameter_count

# デフォルト無効のルールのうち、有効にするもの
opt_in_rules:
Expand Down Expand Up @@ -39,7 +41,7 @@ excluded:
- Carthage/

# 1行あたりの文字数制限変更
line_length: 120
line_length: 200

# 変数名に関する制約
identifier_name:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@
AA31E7F828EAD00B00DCE061 /* FloatingActionButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA31E7F728EAD00B00DCE061 /* FloatingActionButtonView.swift */; };
AA31E7FA28F542C700DCE061 /* TestView1.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA31E7F928F542C700DCE061 /* TestView1.swift */; };
AA31E7FC28F542D900DCE061 /* TestView2.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA31E7FB28F542D900DCE061 /* TestView2.swift */; };
AADD20EC292B6A45008EE02E /* PublishingSettingToggleButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AADD20EB292B6A45008EE02E /* PublishingSettingToggleButtonView.swift */; };
AA31E800290F9C9F00DCE061 /* TabBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA31E7FF290F9C9F00DCE061 /* TabBarView.swift */; };
AADD20EC292B6A45008EE02E /* PublishingSettingToggleButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AADD20EB292B6A45008EE02E /* PublishingSettingToggleButtonView.swift */; };
AB2187C829A21CBF00B54172 /* SignupPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB2187C729A21CBF00B54172 /* SignupPage.swift */; };
AB2187CA29A3412600B54172 /* PullDownSelectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB2187C929A3412600B54172 /* PullDownSelectView.swift */; };
ABAE5BEB28604E4A008ED665 /* .swiftlint.yml in Resources */ = {isa = PBXBuildFile; fileRef = ABAE5BEA28604E4A008ED665 /* .swiftlint.yml */; };
ABAF1D1B283B78F100F890BC /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABAF1D1A283B78F100F890BC /* ContentView.swift */; };
ABAF1D1D283B78F800F890BC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ABAF1D1C283B78F800F890BC /* Assets.xcassets */; };
ABAF1D20283B78F800F890BC /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ABAF1D1F283B78F800F890BC /* Preview Assets.xcassets */; };
ABBB849929AC67D80066B787 /* SignupViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABBB849829AC67D80066B787 /* SignupViewModel.swift */; };
ABBB849C29AC781B0066B787 /* Register.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABBB849B29AC781B0066B787 /* Register.swift */; };
ABBB849E29AC7AA20066B787 /* SignupService.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABBB849D29AC7AA20066B787 /* SignupService.swift */; };
ABC44B202918F62D00BBE1A6 /* LoginViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABC44B182918F62D00BBE1A6 /* LoginViewModel.swift */; };
ABC44B212918F62D00BBE1A6 /* LoginPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABC44B192918F62D00BBE1A6 /* LoginPage.swift */; };
ABC44B222918F62D00BBE1A6 /* Auth.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABC44B1B2918F62D00BBE1A6 /* Auth.swift */; };
Expand All @@ -36,13 +41,18 @@
AA31E7F728EAD00B00DCE061 /* FloatingActionButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FloatingActionButtonView.swift; sourceTree = "<group>"; };
AA31E7F928F542C700DCE061 /* TestView1.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestView1.swift; sourceTree = "<group>"; };
AA31E7FB28F542D900DCE061 /* TestView2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestView2.swift; sourceTree = "<group>"; };
AADD20EB292B6A45008EE02E /* PublishingSettingToggleButtonView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PublishingSettingToggleButtonView.swift; sourceTree = "<group>"; };
AA31E7FF290F9C9F00DCE061 /* TabBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarView.swift; sourceTree = "<group>"; };
AADD20EB292B6A45008EE02E /* PublishingSettingToggleButtonView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PublishingSettingToggleButtonView.swift; sourceTree = "<group>"; };
AB2187C729A21CBF00B54172 /* SignupPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignupPage.swift; sourceTree = "<group>"; };
AB2187C929A3412600B54172 /* PullDownSelectView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PullDownSelectView.swift; sourceTree = "<group>"; };
ABAE5BEA28604E4A008ED665 /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .swiftlint.yml; sourceTree = "<group>"; };
ABAF1D15283B78F100F890BC /* portfolio-ios-swiftui.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "portfolio-ios-swiftui.app"; sourceTree = BUILT_PRODUCTS_DIR; };
ABAF1D1A283B78F100F890BC /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
ABAF1D1C283B78F800F890BC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
ABAF1D1F283B78F800F890BC /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
ABBB849829AC67D80066B787 /* SignupViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignupViewModel.swift; sourceTree = "<group>"; };
ABBB849B29AC781B0066B787 /* Register.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Register.swift; sourceTree = "<group>"; };
ABBB849D29AC7AA20066B787 /* SignupService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignupService.swift; sourceTree = "<group>"; };
ABC44B182918F62D00BBE1A6 /* LoginViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginViewModel.swift; sourceTree = "<group>"; };
ABC44B192918F62D00BBE1A6 /* LoginPage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginPage.swift; sourceTree = "<group>"; };
ABC44B1B2918F62D00BBE1A6 /* Auth.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Auth.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -74,6 +84,17 @@
path = Organism;
sourceTree = "<group>";
};
AB2187C629A21C9300B54172 /* SignUp */ = {
isa = PBXGroup;
children = (
ABBB849A29AC77F60066B787 /* Model */,
ABBB849529AC45E50066B787 /* ViewModel */,
ABBB849729AC45F50066B787 /* Service */,
AB2187C729A21CBF00B54172 /* SignupPage.swift */,
);
path = SignUp;
sourceTree = "<group>";
};
ABAF1D0C283B78F100F890BC = {
isa = PBXGroup;
children = (
Expand All @@ -94,6 +115,7 @@
ABAF1D17283B78F100F890BC /* portfolio-ios-swiftui */ = {
isa = PBXGroup;
children = (
AB2187C629A21C9300B54172 /* SignUp */,
ABB3AD30284DEA84004C012E /* View */,
ABC44B162918F62D00BBE1A6 /* Login */,
ABAF1D1A283B78F100F890BC /* ContentView.swift */,
Expand Down Expand Up @@ -122,6 +144,30 @@
path = View;
sourceTree = "<group>";
};
ABBB849529AC45E50066B787 /* ViewModel */ = {
isa = PBXGroup;
children = (
ABBB849829AC67D80066B787 /* SignupViewModel.swift */,
);
path = ViewModel;
sourceTree = "<group>";
};
ABBB849729AC45F50066B787 /* Service */ = {
isa = PBXGroup;
children = (
ABBB849D29AC7AA20066B787 /* SignupService.swift */,
);
path = Service;
sourceTree = "<group>";
};
ABBB849A29AC77F60066B787 /* Model */ = {
isa = PBXGroup;
children = (
ABBB849B29AC781B0066B787 /* Register.swift */,
);
path = Model;
sourceTree = "<group>";
};
ABC44B162918F62D00BBE1A6 /* Login */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -170,6 +216,7 @@
AA31E7F928F542C700DCE061 /* TestView1.swift */,
AA31E7FB28F542D900DCE061 /* TestView2.swift */,
AADD20EB292B6A45008EE02E /* PublishingSettingToggleButtonView.swift */,
AB2187C929A3412600B54172 /* PullDownSelectView.swift */,
);
path = Atom;
sourceTree = "<group>";
Expand Down Expand Up @@ -269,22 +316,26 @@
ABC44B232918F62D00BBE1A6 /* User.swift in Sources */,
ABDA951F286996FA00C7C735 /* TextView.swift in Sources */,
0483FA3C290669BC001866C9 /* IconView.swift in Sources */,
ABBB849929AC67D80066B787 /* SignupViewModel.swift in Sources */,
AB2187CA29A3412600B54172 /* PullDownSelectView.swift in Sources */,
ABAF1D1B283B78F100F890BC /* ContentView.swift in Sources */,
AA31E800290F9C9F00DCE061 /* TabBarView.swift in Sources */,
AA31E7F828EAD00B00DCE061 /* FloatingActionButtonView.swift in Sources */,
AA31E7FA28F542C700DCE061 /* TestView1.swift in Sources */,
0CFE7BC3286A2A6500CA5119 /* ButtonView.swift in Sources */,
ABC44B212918F62D00BBE1A6 /* LoginPage.swift in Sources */,
AB2187C829A21CBF00B54172 /* SignupPage.swift in Sources */,
ABC44B252918F62D00BBE1A6 /* LoginService.swift in Sources */,
ABBB849E29AC7AA20066B787 /* SignupService.swift in Sources */,
FC7EC30D28EAC89300600302 /* TextField.swift in Sources */,
AADD20EC292B6A45008EE02E /* PublishingSettingToggleButtonView.swift in Sources */,
ABAF1D19283B78F100F890BC /* portfolio_ios_swiftuiApp.swift in Sources */,
ABC44B242918F62D00BBE1A6 /* APIServiceError.swift in Sources */,
FC06F9E9288E85110016E401 /* ColorExtension.swift in Sources */,
ABC44B202918F62D00BBE1A6 /* LoginViewModel.swift in Sources */,
ABC44B272918F93200BBE1A6 /* portfolio_ios_swiftuiApp.swift in Sources */,
AA31E7FC28F542D900DCE061 /* TestView2.swift in Sources */,
ABC44B222918F62D00BBE1A6 /* Auth.swift in Sources */,
ABBB849C29AC781B0066B787 /* Register.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "userIcon_plus.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import SwiftUI
struct LoginPage: View {
@ObservedObject var login = LoginViewModel()

@State var new_login: Bool = false
@State var new_register: Bool = false

var body: some View {
VStack {
VStack(alignment: .leading) {
Expand Down Expand Up @@ -55,12 +58,17 @@ struct LoginPage: View {
.padding(.top, 30)

BaseButtonView(
action: {},
action: {
self.new_register.toggle()
},
labelText: "新規会員登録",
foregroundColor: Color.text,
backgroundColor: Color.grayBottonColor,
radius: 25
)
.fullScreenCover(isPresented: self.$new_register) {
SignupPage()
}
.padding(.top, 60)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// SignupModel.swift
// portfolio-ios-swiftui
//
// Created by 鳥山英峻 on 2023/02/27.
//

import Foundation

struct Register: Codable {
let userID: String
// let oneTimePass: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// SignupService.swift
// portfolio-ios-swiftui
//
// Created by 鳥山英峻 on 2023/02/27.
//

import Foundation

final class SignupAPIService {

static let shared = SignupAPIService()
private init() {}

public func fetchSignupService(displayName: String, userIcon: String, familyName: String, firstName: String, mail: String, password: String, grade: String, course: String) async throws -> Register {

let body: [String: String] = [
"icon": "\(userIcon)",
"familyName": "\(familyName)",
"firstName": "\(firstName)",
"mail": "\(mail)",
"password": "\(password)",
"grade": "\(grade)",
"course": "\(course)",
"displayName": "\(displayName)"
]

// MARK: - 1.API取得先URLの作成
// 本番環境ではURLを変更する
let baseURL: URL = .init(string: "http://localhost:9000/sign/up")!
var request = URLRequest(url: baseURL)

// MARK: - 2.URLリクエストの作成
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: body, options: .fragmentsAllowed)

// MARK: - 3.TASKの作成
let data = try await URLSession.shared.data(for: request)
let response = try JSONDecoder().decode(Register.self, from: data.0)

return response
}
}
121 changes: 121 additions & 0 deletions portfolio-ios-swiftui/portfolio-ios-swiftui/SignUp/SignupPage.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
//
// SignupPage.swift
// portfolio-ios-swiftui
//
// Created by 鳥山英峻 on 2023/02/19.
//

import SwiftUI

struct SignupPage: View {

@ObservedObject var signup = SignupViewModel()
@State var end_register: Bool = false

let gradeList = ["学部1年", "学部2年", "学部3年", "学部4年","修士1年","修士2年","博士1年","博士2年","博士3年"]
let courseList = ["情報システムコース","情報デザインコース","複雑系コース","知能システムコース","情報アーキテクチャ領域","高度ICT領域","メディアデザイン領域","複雑系情報科学領域","知能情報科学領域"]

var body: some View {
VStack {
// MARK: - backbutton処理
Button(action: {
// アニメーションを削除する処理
var transaction = Transaction()
transaction.disablesAnimations = true
withTransaction(transaction) {
end_register = true
}
}) {
Image(systemName: "chevron.backward")
.resizable()
.scaledToFit()
.font(.system(size: 20, weight: .bold))
.frame(height: 20.0)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.leading, 20)
.foregroundColor(.gray)
}
.fullScreenCover(isPresented: $end_register) {
LoginPage()
}
// MARK: - 入力フォーム処理

ScrollView {
VStack {
VStack {
HStack {
TextView(text: "表示名", textPattern: 0)
TextField("", text: $signup.displayName)
.frame(width: 140, height: 50)
.padding(.leading, 15)
.overlay(RoundedRectangle(cornerRadius: 15)
.stroke(Color.grayBottonColor, lineWidth: 2)
)
.padding(.leading, 10)

Image("userIcon_plus")
.resizable()
.scaledToFit()
.frame(width: 90, height: 90)
.padding(.leading, 25)
}
Text("※ '表示名'は第三者に公開されます")
.foregroundColor(.gray)
}
.padding(.bottom, 20)

VStack(spacing: 15) {
HStack {
TextView(text: "姓", textPattern: 0)
TextField("", text: $signup.familyName)
.frame(width: 240, height: 48)
.padding(.leading, 15)
.overlay(RoundedRectangle(cornerRadius: 15)
.stroke(Color.grayBottonColor, lineWidth: 2)
)
.padding(.leading, 25)
}

HStack {
TextView(text: "名", textPattern: 0)
TextField("", text: $signup.firstName)
.frame(width: 240, height: 48)
.padding(.leading, 15)
.overlay(RoundedRectangle(cornerRadius: 15)
.stroke(Color.grayBottonColor, lineWidth: 2)
)
.padding(.leading, 25)
}
}
.padding(.bottom, 20)

VStack(spacing: 20) {
TextBox(fieldHide: false, titleText: "メールアドレス", descriptionText: "学内メールを入力してください", inputText: $signup.mail)
TextBox(fieldHide: true, titleText: "パスワード", descriptionText: "", inputText: $signup.password)
TextBox(fieldHide: true, titleText: "パスワード確認", descriptionText: "", inputText: $signup.checkPassword)
PullDownSelectView(labelName: "学年", selectList: gradeList, selectionLabel: $signup.grade)
PullDownSelectView(labelName: "所属コース", selectList: courseList, selectionLabel: $signup.course)
}
.padding(.bottom, 40)

// MARK: - 登録処理

BaseButtonView(
action: {
signup.fetchSignupService()
},
labelText: "新規会員登録",
foregroundColor: Color.white,
backgroundColor: Color.subPink, radius: 25
)
}
}
}
}
}

struct SignupPage_Previews: PreviewProvider {
static var previews: some View {
SignupPage()
}
}
Loading