feat: 🚧 Create two screens
This commit is contained in:
parent
9358bfe709
commit
78f2aedcd8
@ -11,6 +11,9 @@
|
|||||||
2CCE3EA12AF678B200BB0ED3 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CCE3EA02AF678B200BB0ED3 /* ContentView.swift */; };
|
2CCE3EA12AF678B200BB0ED3 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CCE3EA02AF678B200BB0ED3 /* ContentView.swift */; };
|
||||||
2CCE3EA32AF678B300BB0ED3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2CCE3EA22AF678B300BB0ED3 /* Assets.xcassets */; };
|
2CCE3EA32AF678B300BB0ED3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2CCE3EA22AF678B300BB0ED3 /* Assets.xcassets */; };
|
||||||
2CCE3EA62AF678B300BB0ED3 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2CCE3EA52AF678B300BB0ED3 /* Preview Assets.xcassets */; };
|
2CCE3EA62AF678B300BB0ED3 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2CCE3EA52AF678B300BB0ED3 /* Preview Assets.xcassets */; };
|
||||||
|
2CCE3EAD2AF67A9000BB0ED3 /* UtilsFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CCE3EAC2AF67A9000BB0ED3 /* UtilsFunctions.swift */; };
|
||||||
|
2CCE3EAF2AF67BA900BB0ED3 /* BinaryConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CCE3EAE2AF67BA900BB0ED3 /* BinaryConverter.swift */; };
|
||||||
|
2CCE3EB12AF67CFD00BB0ED3 /* HexaConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CCE3EB02AF67CFD00BB0ED3 /* HexaConverter.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
@ -19,6 +22,9 @@
|
|||||||
2CCE3EA02AF678B200BB0ED3 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
2CCE3EA02AF678B200BB0ED3 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||||
2CCE3EA22AF678B300BB0ED3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
2CCE3EA22AF678B300BB0ED3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
2CCE3EA52AF678B300BB0ED3 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
|
2CCE3EA52AF678B300BB0ED3 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
|
||||||
|
2CCE3EAC2AF67A9000BB0ED3 /* UtilsFunctions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UtilsFunctions.swift; sourceTree = "<group>"; };
|
||||||
|
2CCE3EAE2AF67BA900BB0ED3 /* BinaryConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BinaryConverter.swift; sourceTree = "<group>"; };
|
||||||
|
2CCE3EB02AF67CFD00BB0ED3 /* HexaConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HexaConverter.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@ -53,6 +59,9 @@
|
|||||||
children = (
|
children = (
|
||||||
2CCE3E9E2AF678B200BB0ED3 /* BinaryConverterApp.swift */,
|
2CCE3E9E2AF678B200BB0ED3 /* BinaryConverterApp.swift */,
|
||||||
2CCE3EA02AF678B200BB0ED3 /* ContentView.swift */,
|
2CCE3EA02AF678B200BB0ED3 /* ContentView.swift */,
|
||||||
|
2CCE3EB02AF67CFD00BB0ED3 /* HexaConverter.swift */,
|
||||||
|
2CCE3EAE2AF67BA900BB0ED3 /* BinaryConverter.swift */,
|
||||||
|
2CCE3EAC2AF67A9000BB0ED3 /* UtilsFunctions.swift */,
|
||||||
2CCE3EA22AF678B300BB0ED3 /* Assets.xcassets */,
|
2CCE3EA22AF678B300BB0ED3 /* Assets.xcassets */,
|
||||||
2CCE3EA42AF678B300BB0ED3 /* Preview Content */,
|
2CCE3EA42AF678B300BB0ED3 /* Preview Content */,
|
||||||
);
|
);
|
||||||
@ -138,6 +147,9 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
2CCE3EA12AF678B200BB0ED3 /* ContentView.swift in Sources */,
|
2CCE3EA12AF678B200BB0ED3 /* ContentView.swift in Sources */,
|
||||||
|
2CCE3EAF2AF67BA900BB0ED3 /* BinaryConverter.swift in Sources */,
|
||||||
|
2CCE3EAD2AF67A9000BB0ED3 /* UtilsFunctions.swift in Sources */,
|
||||||
|
2CCE3EB12AF67CFD00BB0ED3 /* HexaConverter.swift in Sources */,
|
||||||
2CCE3E9F2AF678B200BB0ED3 /* BinaryConverterApp.swift in Sources */,
|
2CCE3E9F2AF678B200BB0ED3 /* BinaryConverterApp.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
18
BinaryConverter/BinaryConverter.swift
Normal file
18
BinaryConverter/BinaryConverter.swift
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
//
|
||||||
|
// BinaryConverter.swift
|
||||||
|
// BinaryConverter
|
||||||
|
//
|
||||||
|
// Created by Louis Gallet on 04/11/2023.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct BinaryConverter: View {
|
||||||
|
var body: some View {
|
||||||
|
Text("Hello, Binary!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#Preview {
|
||||||
|
BinaryConverter()
|
||||||
|
}
|
@ -8,14 +8,14 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
|
@State private var selectedTab = 0
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
TabView(selection: $selectedTab,
|
||||||
Image(systemName: "globe")
|
content: {
|
||||||
.imageScale(.large)
|
BinaryConverter().tabItem { Image(systemName: "1.square.fill") ; Text("Binary") }.tag(0)
|
||||||
.foregroundStyle(.tint)
|
HexaConverter().tabItem { Image(systemName: "2.square.fill") ; Text("Hexa") }.tag(1)
|
||||||
Text("Hello, world!")
|
|
||||||
}
|
})
|
||||||
.padding()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
BinaryConverter/HexaConverter.swift
Normal file
18
BinaryConverter/HexaConverter.swift
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
//
|
||||||
|
// HexaConverter.swift
|
||||||
|
// BinaryConverter
|
||||||
|
//
|
||||||
|
// Created by Louis Gallet on 04/11/2023.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct HexaConverter: View {
|
||||||
|
var body: some View {
|
||||||
|
Text("Hello, Hexa!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#Preview {
|
||||||
|
HexaConverter()
|
||||||
|
}
|
28
BinaryConverter/UtilsFunctions.swift
Normal file
28
BinaryConverter/UtilsFunctions.swift
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
//
|
||||||
|
// UtilsFunctions.swift
|
||||||
|
// BinaryConverter
|
||||||
|
//
|
||||||
|
// Created by Louis Gallet on 04/11/2023.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
extension BinaryInteger {
|
||||||
|
var binaryDescription: String {
|
||||||
|
/// Convert a given number to it's binary representation
|
||||||
|
/// source: https://stackoverflow.com/questions/26181221/how-to-convert-a-decimal-number-to-binary-in-swift
|
||||||
|
var binaryString = ""
|
||||||
|
var internalNumber = self
|
||||||
|
var counter = 0
|
||||||
|
|
||||||
|
for _ in (1...self.bitWidth) {
|
||||||
|
binaryString.insert(contentsOf: "\(internalNumber & 1)", at: binaryString.startIndex)
|
||||||
|
internalNumber >>= 1
|
||||||
|
counter += 1
|
||||||
|
if counter % 4 == 0 {
|
||||||
|
binaryString.insert(contentsOf: " ", at: binaryString.startIndex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return binaryString
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user