//
//  Tab01.swift
//  TabBar_Tutorial
//
//  Created by devdepot on 2021/04/28.
//

import SwiftUI

struct tab01: View {
    
    var body: some View{
        
        TabView{
            //보여질 화면
            MyTab01()
                .background(Color.blue)
                .tabItem {
                    Image(systemName: "airplane")
                    Text("1번")
                }
                .tag(0)
            
            MyTab02()
                .tabItem {
                    Image(systemName: "flame.fill")
                    Text("2번")
                }
                .tag(1)
            
            MyTab03()
                .tabItem {
                    Image(systemName: "doc.fill")
                    Text("3번")
                }
                .tag(2)
            
        }
           
    }
}

struct MyTab01: View {
    var body: some View{
     
        GeometryReader{ geo in
           
            HStack{
                Spacer()
                VStack{
                    Spacer()
                    Text("1번")
                        .font(.largeTitle)
                        .fontWeight(.bold)
                        .foregroundColor(Color.white)
                    Spacer()
                }
                Spacer()
            }
        }.background(Color.blue)
        .edgesIgnoringSafeArea(.all)
        
    }
}

struct MyTab02: View {
    var body: some View{
     
        GeometryReader{ geo in
           
            HStack{
                Spacer()
                VStack{
                    Spacer()
                    Text("2번")
                        .font(.largeTitle)
                        .fontWeight(.bold)
                        .foregroundColor(Color.white)
                    Spacer()
                }
                Spacer()
            }
        }.background(Color.orange)
        .edgesIgnoringSafeArea(.all)
        
    }
}

struct MyTab03: View {
    var body: some View{
     
        GeometryReader{ geo in
           
            HStack{
                Spacer()
                VStack{
                    Spacer()
                    Text("3번")
                        .font(.largeTitle)
                        .fontWeight(.bold)
                        .foregroundColor(Color.white)
                    Spacer()
                }
                Spacer()
            }
        }.background(Color.green)
        .edgesIgnoringSafeArea(.all)
        
    }
}

struct tab01_Previews: PreviewProvider {
    static var previews: some View {
        tab01()
    }
}

'IOS > SwiftUI' 카테고리의 다른 글

(SwiftUI)13.TextField  (0) 2021.04.28
(SwiftUI)12.커스톰 탭뷰  (0) 2021.04.28
(SwiftUI)10.GeometryReader,enum,애니메이션  (0) 2021.04.28
(SwiftUI)09.리스트뷰  (0) 2021.04.27
(SwiftUI)08. 동적 뷰 넣기, 스택 연습,Alert  (0) 2021.04.27
//
//  testGeomerty.swift
//  GeoMertyReader_Tutorial
//
//  Created by devdepot on 2021/04/28.
//

import SwiftUI

enum Index {
    case one,two,three
}


struct testGeomerty: View {
    
    @State var index : Index = .one
    
    var body: some View{
        
        GeometryReader{ rate in
            HStack{
                Spacer()
                VStack(alignment: .center){
                    
                    Button(action: {
                        print("1번이 클릭 되었습니다.")
                        withAnimation{
                            self.index = .one
                        }
                        
                    }, label: {
                        Text("1")
                           .font(.largeTitle)
                            .frame(width: 100,height:rate.size.height/3)
                            .padding(.horizontal,self.index == .one ? 100 : 0)
                           .background(Color.red)
                           .foregroundColor(Color.white)
                    })
                    
                    Button(action: {
                        print("2번이 클릭 되었습니다.")
                        withAnimation{
                            self.index = .two
                        }
                        
                    }, label: {
                        Text("2")
                           .font(.largeTitle)
                           .frame(width: 100,height:rate.size.height/3)
                            .padding(.horizontal,self.index == .two ? 100 : 0)
                           .background(Color.blue)
                           .foregroundColor(Color.white)
                    })
                    
                    Button(action: {
                        print("3번이 클릭 되었습니다.")
                        withAnimation{
                            self.index = .three
                        }
                       
                    }, label: {
                        Text("3")
                           .font(.largeTitle)
                           .frame(width: 100,height:rate.size.height/3)
                            .padding(.horizontal,self.index == .three ? 100 : 0)
                           .background(Color.green)
                           .foregroundColor(Color.white)
                       })
                  
                 
              
            }//vstack
                Spacer()
            }//hstack
            
        }
        .background(Color.yellow)
        .edgesIgnoringSafeArea(.all)
    }
    
}

struct testGeomerty_Previews: PreviewProvider {
    static var previews: some View{
        testGeomerty()
    }
}

'IOS > SwiftUI' 카테고리의 다른 글

(SwiftUI)12.커스톰 탭뷰  (0) 2021.04.28
(SwiftUI)11.탭뷰  (0) 2021.04.28
(SwiftUI)09.리스트뷰  (0) 2021.04.27
(SwiftUI)08. 동적 뷰 넣기, 스택 연습,Alert  (0) 2021.04.27
(SwiftUI)07.Stack 정리  (0) 2021.04.27

-contentView-

66라인이 포인트

//
//  ContentView.swift
//  Swift_stack_practice_tutorial
//
//  Created by devdepot on 2021/04/27.
//

import SwiftUI

struct ContentView: View {
    
    @State var isNavigationBarHidden : Bool = false
    
    var body: some View {
        NavigationView{
            ZStack(alignment: .bottomTrailing){
                
                VStack(alignment:.leading){
                    
                    HStack{
                        NavigationLink(
                            destination: MyList(),
                            label: {
                                Image(systemName: "line.horizontal.3")
                                    .font(.largeTitle)
                                    .foregroundColor(.black)
                            })
                            
                        Spacer()
                        Image(systemName: "person.crop.circle.fill")
                            .font(.largeTitle)
                    }.padding(.horizontal,20)
                    
                    Text("이일팔 할 일 목록")
                        .fontWeight(.bold)
                        .font(.system(size: 30))
                        
                    ScrollView{
                        VStack{
                            MyProjectCard()
                            MyBasicCard()
                            MyCard(icon: "doc.fill", title: "책읽기", start: "오전 9시", end: "오후 3시", bgColor: Color.green)
                            MyCard(icon: "tray.fill", title: "책읽기", start: "오전 9시", end: "오후 3시", bgColor: Color.green)
                            MyCard(icon: "doc.fill", title: "책읽기", start: "오전 9시", end: "오후 3시", bgColor: Color.green)
                            MyCard(icon: "doc.fill", title: "책읽기", start: "오전 9시", end: "오후 3시", bgColor: Color.green)
                            MyCard(icon: "doc.fill", title: "책읽기", start: "오전 9시", end: "오후 3시", bgColor: Color.green)
                        }
    //                    .padding()
                    }
                }.padding(.top,20)
                .padding(.horizontal,20)
                
            
                
                Circle()
                    .frame(width: 50, height: 50,alignment: .center)
                    .foregroundColor(.yellow)
                    .overlay(Image(systemName: "plus")
                                .font(.system(size: 30))
                                .foregroundColor(.white))
                    .padding(.trailing,10)
                    .shadow(radius: 20)
            }//zstack
            
            .navigationBarTitle("메인")
            .navigationBarHidden(self.isNavigationBarHidden)
            .onAppear{
                self.isNavigationBarHidden = true;
            }
            
        }   //navigation view
       
       
        
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

-MyList-

//
//  MyList.swift
//  Swift_stack_practice_tutorial
//
//  Created by devdepot on 2021/04/27.
//

import SwiftUI


struct MyList : View {

    
    var body: some View{
       
//        List{
//            Text("마이리스트")
//            Text("마이리스트")
//            Text("마이리스트")
//            Text("마이리스트")
//            Text("마이리스트")
//            Text("마이리스트")
//        }
        
//        List{
//            ForEach(1...10, id: \.self){
//                Text("마이리스트 \($0)")
//            }
//        }
//        Text("마이리스트")
        
        List{
            Section(header: Text("오늘 할일")
                        .font(.headline),footer: Text("푸터")){
                ForEach(1...3, id: \.self){ itemIndex in
                   
                    
                    MyCard(icon: "doc.fill", title: "책읽기\(itemIndex)", start: "오전 9시", end: "오후 3시", bgColor: Color.green)
                }
            }.listRowInsets(EdgeInsets.init(top:10,leading: 10,bottom: 10,trailing: 10))  //행 간격
            .listRowBackground(Color.yellow)
            
            Section(header: Text("내일 할일")){
                ForEach(1...20, id: \.self){ itemIndex in
                   
                    
                    MyCard(icon: "doc.fill", title: "책읽기\(itemIndex)", start: "오전 9시", end: "오후 3시", bgColor: Color.blue)
                }
            }
            
            Section(header: Text("헤더입니다.")){
                ForEach(1...3, id: \.self){ itemIndex in
                   
                    
                    MyCard(icon: "doc.fill", title: "책읽기\(itemIndex)", start: "오전 9시", end: "오후 3시", bgColor: Color.yellow)
                }
            }
           
        }
        .listStyle(GroupedListStyle())
        .navigationBarTitle("내 목록") //네비게이션 바 타이틀
    }
}


struct MyList_Previews: PreviewProvider {
    static var previews: some View {
        MyList()
    }
}

'IOS > SwiftUI' 카테고리의 다른 글

(SwiftUI)11.탭뷰  (0) 2021.04.28
(SwiftUI)10.GeometryReader,enum,애니메이션  (0) 2021.04.28
(SwiftUI)08. 동적 뷰 넣기, 스택 연습,Alert  (0) 2021.04.27
(SwiftUI)07.Stack 정리  (0) 2021.04.27
(SwiftUI)06.CircleImage  (0) 2021.04.27

-contentview-

//
//  ContentView.swift
//  Swift_stack_practice_tutorial
//
//  Created by devdepot on 2021/04/27.
//

import SwiftUI

struct ContentView: View {
    var body: some View {
        
        ZStack(alignment: .bottomTrailing){
            
            VStack(alignment:.leading){
                
                HStack{
                        Image(systemName: "line.horizontal.3")
                            .font(.largeTitle)
                    Spacer()
                    Image(systemName: "person.crop.circle.fill")
                        .font(.largeTitle)
                }.padding(.horizontal,20)
                
                Text("이일팔 할 일 목록")
                    .fontWeight(.bold)
                    .font(.system(size: 30))
                    
                ScrollView{
                    VStack{
                        MyProjectCard()
                        MyBasicCard()
                        MyCard(icon: "doc.fill", title: "책읽기", start: "오전 9시", end: "오후 3시", bgColor: Color.green)
                        MyCard(icon: "tray.fill", title: "책읽기", start: "오전 9시", end: "오후 3시", bgColor: Color.green)
                        MyCard(icon: "doc.fill", title: "책읽기", start: "오전 9시", end: "오후 3시", bgColor: Color.green)
                        MyCard(icon: "doc.fill", title: "책읽기", start: "오전 9시", end: "오후 3시", bgColor: Color.green)
                        MyCard(icon: "doc.fill", title: "책읽기", start: "오전 9시", end: "오후 3시", bgColor: Color.green)
                    }
//                    .padding()
                }
            }.padding(.top,20)
            .padding(.horizontal,20)
            
        
            
            Circle()
                .frame(width: 50, height: 50,alignment: .center)
                .foregroundColor(.yellow)
                .overlay(Image(systemName: "plus")
                            .font(.system(size: 30))
                            .foregroundColor(.white))
                .padding(.trailing,10)
                .shadow(radius: 20)
        }
       
        
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

-MyProjectCard-

//
//  MyProjectCard.swift
//  Swift_stack_practice_tutorial
//
//  Created by devdepot on 2021/04/27.
//

import SwiftUI

struct MyProjectCard : View{
    
    @State var shouldShowAlert: Bool = false
        
    var body: some View{
        VStack(alignment: .leading){
            Rectangle().frame(height:0)
            Text("이일팔 프로젝트")
                .font(.system(size: 23))
                .fontWeight(.black)
                .padding(.bottom,5)
            Text("10 AM  - 11 AM")
                .foregroundColor(.secondary)
                .padding(.bottom,10)
//            Divider()
            HStack{
               
                Image("1")
                .resizable()
                    .frame(width: 50, height: 50)
                    .clipShape(/*@START_MENU_TOKEN@*/Circle()/*@END_MENU_TOKEN@*/)
                    .overlay(Circle()
                                .stroke(lineWidth: 5)
                                .foregroundColor(Color.orange))
                    
                
                Image("2")
                    .resizable()
                    .frame(width: 50,height:50)
                
                Image("3")
                    .resizable()
                    .frame(width: 50,height:50)
                
                Spacer()
                
                //
                Button(action: {
                    print("버튼 클릭")
                    
                    self.shouldShowAlert = true
                }
                ){
                    Text("확인")
                        .fontWeight(.bold)
                        .foregroundColor(.white)
                        .padding()
                        .background(Color.blue)
                        .cornerRadius(20)
                        .frame(width:80)
                }.alert(isPresented: $shouldShowAlert){
                    Alert(title: Text("알림창입니다!"))
                }
                
               
                
            }
        }
        .padding(30)
        .background(Color.yellow)
        .cornerRadius(20)
        
    }
}

-MyBasicCard-

//
//  MyBasicCard.swift
//  Swift_stack_practice_tutorial
//
//  Created by devdepot on 2021/04/27.
//

import SwiftUI

struct MyBasicCard : View{
    
    var body: some View{
        
        HStack(spacing:20){
            Image(systemName: "flame.fill")
                .font(.system(size: 40))
                .foregroundColor(.white)
//                .frame(width:100,height: 100)
            
            VStack(alignment: .leading){
                Rectangle().frame(height:0)
                Text("하하하")
                    .fontWeight(.bold)
                    .font(.system(size: 25))
                    .foregroundColor(.white)
                
                Spacer().frame(height:5)
                Text("하하하")
                    .foregroundColor(.white)
            }
        }
        .padding(20)
        .background(Color.purple)
        .cornerRadius(20)
}

}

 

-MyCard(동적)-

//
//  MyBasicCard.swift
//  Swift_stack_practice_tutorial
//
//  Created by devdepot on 2021/04/27.
//

import SwiftUI

struct MyCard : View{
    
    var icon : String
    var title : String
    var start : String
    var end : String
    var bgColor : Color
    
    var body: some View{
        
       
        HStack(spacing:20){
            Image(systemName: icon)
                .font(.system(size: 40))
                .foregroundColor(.white)
//                .frame(width:100,height: 100)
            
            VStack(alignment: .leading){
                Rectangle().frame(height:0)
                Text(title)
                    .fontWeight(.bold)
                    .font(.system(size: 25))
                    .foregroundColor(.white)
                
                Spacer().frame(height:5)
                Text("\(start) ~ \(end)")
                    .foregroundColor(.white)
            }
        }
        .padding(20)
        .background(bgColor)
        .cornerRadius(20)
}

}

struct MyCard_Previews: PreviewProvider {
    static var previews: some View {
        MyCard(icon: "doc.fill", title: "책읽기", start: "오전 9시", end: "오후 3시", bgColor: Color.green)
    }
}

'IOS > SwiftUI' 카테고리의 다른 글

(SwiftUI)10.GeometryReader,enum,애니메이션  (0) 2021.04.28
(SwiftUI)09.리스트뷰  (0) 2021.04.27
(SwiftUI)07.Stack 정리  (0) 2021.04.27
(SwiftUI)06.CircleImage  (0) 2021.04.27
(SwiftUI)04.웹뷰 띄우기  (0) 2021.04.27

-VStack-

//
//  MyVStack.swift
//  SwiftUI_Statcks_tuturial
//
//  Created by devdepot on 2021/04/27.
//

import SwiftUI

struct MyVstack : View {
    var body: some View {
        VStack(alignment: .center, spacing: 0){
            
//            Spacer()
            Text("글자")
                .font(.system(size: 30))
                .fontWeight(.heavy)
            
            Divider().opacity(0) //선 안보이게
            
            Rectangle()
                .frame(width : 100,height: 100)
                .foregroundColor(Color.red)
            Rectangle()
                .frame(width : 100,height: 100)
                .foregroundColor(Color.yellow)
            
            Spacer()
                .frame(height:50)
            
            Rectangle()
                .frame(width : 100,height: 100)
                .foregroundColor(Color.blue)
                
//            Spacer()
//            Spacer()
        }
//        .edgesIgnoringSafeArea(/*@START_MENU_TOKEN@*/.all/*@END_MENU_TOKEN@*/)
        .frame(width: 300)
        .background(Color.green)
        
       
        
    }
}

-HStack-

 

//
//  MYHStack.swift
//  SwiftUI_Statcks_tuturial
//
//  Created by devdepot on 2021/04/27.
//

import SwiftUI

struct MYHStack : View {
    var body: some View{
        
        HStack(alignment: .center) {
            
//            Divider()
//            Rectangle()
//                .frame(width: 100)
//                .foregroundColor(Color.red)
            
//            Rectangle()
//                .frame(width: 100, height: /*@START_MENU_TOKEN@*/100/*@END_MENU_TOKEN@*/)
//                .foregroundColor(Color.red)
            
            Image(systemName: "flame.fill")
                .foregroundColor(.white)
                .font(.system(size: 70))
            
            Rectangle()
                .frame(width: 100, height: 100)
                .foregroundColor(Color.yellow)
            
            Rectangle()
                .frame(width: 100, height: /*@START_MENU_TOKEN@*/100/*@END_MENU_TOKEN@*/)
                .foregroundColor(Color.blue)
        }
        .padding()
        .background(Color.green)
        
    }
}

struct MYHStack_Previews: PreviewProvider {
    static var previews: some View {
        MYHStack()
    }
}

_ZStack-

//
//  MyZstack.swift
//  SwiftUI_Statcks_tuturial
//
//  Created by devdepot on 2021/04/27.
//

import SwiftUI

struct MyZstack : View {
    
    var body : some View{
    
        ZStack{
            Rectangle()
                .frame(width:100,height: 100)
                .foregroundColor(Color.red)
                .zIndex(1)  //깊이 레벨 설정
            
            Rectangle()
                .frame(width:50,height: 50)
                .foregroundColor(Color.green)
            
            Rectangle()
                .frame(width:25,height: 25)
                .foregroundColor(Color.blue)
        }
    }
}

struct MyZstack_Previews: PreviewProvider {
    static var previews: some View {
        MyZstack()
    }
}

'IOS > SwiftUI' 카테고리의 다른 글

(SwiftUI)09.리스트뷰  (0) 2021.04.27
(SwiftUI)08. 동적 뷰 넣기, 스택 연습,Alert  (0) 2021.04.27
(SwiftUI)06.CircleImage  (0) 2021.04.27
(SwiftUI)04.웹뷰 띄우기  (0) 2021.04.27
(SwiftUI)03.바인딩 @Binding  (0) 2021.04.27

-contentVIew-

//
//  ContentView.swift
//  Image_tutorial
//
//  Created by devdepot on 2021/04/27.
//

import SwiftUI

struct ContentView: View {
    var body: some View {
        NavigationView{
            VStack{
                Image("MyImage")
                    .frame(height:10)
                    .offset(y:-1100)
                CircleImageVIew().padding()
                HStack{
                    NavigationLink(
                        destination: MyWebView(urlToLoad: "https://www.naver.com")
                            .edgesIgnoringSafeArea(.all)
                    ){
                        Text("네이버로 가기")
                            .font(.system(size: 20))
                            .fontWeight(.bold)
                            .foregroundColor(.white)
                            .padding()
                            .background(Color.red)
                            .cornerRadius(20)
                    }
                    
                    NavigationLink(
                        destination: MyWebView(urlToLoad: "https://www.google.com")
                            .edgesIgnoringSafeArea(.all)
                    ){
                        Text("구글로 가기")
                            .font(.system(size: 20))
                            .fontWeight(.bold)
                            .foregroundColor(.white)
                            .padding()
                            .background(Color.orange)
                            .cornerRadius(20)
                    }
                }   //Hstack
                .padding(50)
            }
        }
        
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

 

-circleImage-

//
//  File.swift
//  Image_tutorial
//
//  Created by devdepot on 2021/04/27.
//

import SwiftUI

struct CircleImageVIew: View {
    
    var body: some View{
//        Image(systemName: "flame.fill") //sfSymbol
//            .font(.system(size: 200))
//            .foregroundColor(.blue)
        
        Image("MyImage")
            .resizable()    // 크기 맞추기
            .scaledToFill() //aspectRatio랑 같다
//            .aspectRatio(contentMode: .fill)    //비율 맞추기
            .frame(width: 300,height: 300)
            .clipShape(Circle()) //원형으로 자르기
            .shadow(color: .red, radius: 2, x: 5, y: 10)
            .overlay(Circle()
                        .foregroundColor(Color.black)
                        .opacity(0.4)   //투명도 설정
            )
            .overlay(Circle().stroke(Color.red,lineWidth: 10).padding())
            .overlay(Circle().stroke(Color.yellow,lineWidth: 10))
            .overlay(Text("호호")
                        .foregroundColor(.white)
                        .font(.system(size: 50))
                        .fontWeight(.bold)
            )
//            .clipped()
            .edgesIgnoringSafeArea(/*@START_MENU_TOKEN@*/.all/*@END_MENU_TOKEN@*/)
    }
}

-webView-

 

//
//  MyWebView.swift
//  swiftUI_Webview_tutorial
//
//  Created by devdepot on 2021/04/27.
//

import SwiftUI
import WebKit

// uikit 의 uiView 를 사용할 수 있도록 한다.
// uiViewCOntrollerRepresntable

struct MyWebView: UIViewRepresentable {
    
    var urlToLoad: String
    
    // uiview 만들기
    func makeUIView(context: Context) -> WKWebView {
        
        guard let url = URL(string: self.urlToLoad) else {
            return WKWebView()
        }
        
        //웹뷰 인스턴스 생성
        let webView = WKWebView()
        
        // 웹뷰를 로드한다.
        webView.load(URLRequest(url: url))
        
        return webView
    }
    
    // 업데이트 ui view
    func updateUIView(_ uiView: WKWebView, context: UIViewRepresentableContext<MyWebView>) {
        
    }
}


'IOS > SwiftUI' 카테고리의 다른 글

(SwiftUI)08. 동적 뷰 넣기, 스택 연습,Alert  (0) 2021.04.27
(SwiftUI)07.Stack 정리  (0) 2021.04.27
(SwiftUI)04.웹뷰 띄우기  (0) 2021.04.27
(SwiftUI)03.바인딩 @Binding  (0) 2021.04.27
(SwiftUI)02. 네비게이션,spacer,@state  (0) 2021.04.26

+ Recent posts