generated from shilokuma-inc/template-app-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from shilokuma-inc/feat/data_for_easy
【FEAT】Easy用のデータを用意する
- Loading branch information
Showing
5 changed files
with
142 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// | ||
// ContentView.swift | ||
// PrimePickApp | ||
// | ||
// Created by 村石 拓海 on 2024/04/11. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct MainView: View { | ||
var body: some View { | ||
NavigationStack { | ||
VStack { | ||
Text("PrimePick") | ||
.font(.custom("Helvetica Neue", size: 40)) | ||
.fontWeight(.bold) | ||
.padding(.top, 100) | ||
.padding(.bottom, 30) | ||
|
||
Spacer() | ||
|
||
Text("Select Difficulty") | ||
.font(.headline) | ||
.padding() | ||
|
||
Button(action: { | ||
// Hardボタンのアクション | ||
}) { | ||
Text("Hard") | ||
.padding() | ||
.frame(maxWidth: .infinity) | ||
.background(Color.red) | ||
.foregroundColor(.white) | ||
.cornerRadius(20) | ||
} | ||
.padding(.horizontal, 50) | ||
.padding(.bottom, 10) | ||
|
||
Button(action: { | ||
// Normalボタンのアクション | ||
}) { | ||
Text("Normal") | ||
.padding() | ||
.frame(maxWidth: .infinity) | ||
.background(Color.blue) | ||
.foregroundColor(.white) | ||
.cornerRadius(20) | ||
} | ||
.padding(.horizontal, 50) | ||
.padding(.bottom, 10) | ||
|
||
NavigationLink(destination: QuizView()) { | ||
Text("Easy") | ||
.padding() | ||
.frame(maxWidth: .infinity) | ||
.background(Color.green) | ||
.foregroundColor(.white) | ||
.cornerRadius(20) | ||
} | ||
.padding(.horizontal, 50) | ||
|
||
Spacer() | ||
} | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
MainView() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// PrimeData.swift | ||
// PrimePickApp | ||
// | ||
// Created by 村石 拓海 on 2024/05/15. | ||
// | ||
|
||
import Foundation | ||
|
||
final class PrimeData { | ||
init() {} | ||
|
||
public func generateOneOrTwoDigitPrimes() -> [Int] { | ||
var twoDigitPrimes = [Int]() | ||
outerLoop: for num in 3..<100 { | ||
for i in 2..<num { | ||
if num % i == 0 { | ||
continue outerLoop | ||
} | ||
} | ||
twoDigitPrimes.append(num) | ||
} | ||
return twoDigitPrimes | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// QuizView.swift | ||
// PrimePickApp | ||
// | ||
// Created by 村石 拓海 on 2024/05/15. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct QuizView: View { | ||
let primeData = PrimeData() | ||
var primes: [Int] | ||
init() { | ||
primes = primeData.generateOneOrTwoDigitPrimes() | ||
} | ||
|
||
var body: some View { | ||
List(primes, id: \.self) { prime in | ||
Text("\(prime)") | ||
} | ||
.navigationTitle("Primes") | ||
} | ||
} | ||
|
||
#Preview { | ||
QuizView() | ||
} |