You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
//
|
|
|
|
// ContentView.swift
|
|
|
|
// Weibo
|
|
|
|
//
|
|
|
|
// Created by Qihua Pan on 2020/8/16.
|
|
|
|
// Copyright © 2020 Qihua Pan. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
import CoreData
|
|
|
|
|
|
|
|
struct ContentView: View {
|
|
|
|
|
|
|
|
@Environment(\.managedObjectContext) var contenxt:NSManagedObjectContext
|
|
|
|
|
|
|
|
@EnvironmentObject var user:User
|
|
|
|
|
|
|
|
@State var selection=2
|
|
|
|
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
TabView(selection: self.$selection) {
|
|
|
|
if (self.user.access_token != nil){
|
|
|
|
IndexView().tabItem { VStack {
|
|
|
|
Image("house")
|
|
|
|
Text("首页")
|
|
|
|
.foregroundColor(Color.black)
|
|
|
|
} }.tag(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
LoginView().tabItem { VStack {
|
|
|
|
Image("user")
|
|
|
|
Text("我")
|
|
|
|
} }.tag(2)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ContentView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
ContentView().environment(\.managedObjectContext, UserData.getContext()).environmentObject(UserData.getUser())
|
|
|
|
}
|
|
|
|
}
|