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.
weibo/Weibo/IndexView.swift

107 lines
2.4 KiB

4 years ago
//
// IndexView.swift
// Weibo
//
// Created by Qihua Pan on 2020/8/18.
// Copyright © 2020 Qihua Pan. All rights reserved.
//
import SwiftUI
import AlamofireImage
struct TopView:View {
@Binding var icon: String
var body: some View{
VStack {
HStack(alignment: .center){
Button(action: {
if self.icon=="arrowbottom"{
self.icon="arrowtop"
}else{
self.icon="arrowbottom"
}
}) {
HStack {
Text("最新微博")
.foregroundColor(Color.black)
Image(self.icon)
}
}
Button(action: {
print("推荐")
}){
Text("推荐")
.foregroundColor(Color.gray)
}
Button(action: {
print("同城")
}){
Text("同城")
.foregroundColor(Color.gray)
}
}
if self.icon=="arrowtop"{
HStack {
Text("默认分组")
.foregroundColor(Color.gray)
Spacer()
Button(action: {
print("编辑分组")
}){
Text("编辑")
.foregroundColor(Color.orange)
}
}
}
}
}
}
struct ImageView:View {
@Binding var imageUrl:String
var body: some View{
Image(uiImage: requestImage(url: imageUrl))
}
func requestImage(url:String)->UIImage{
let data = try! Data(contentsOf: URL(string: url)!)
let image = UIImage(data: data, scale: UIScreen.main.scale)!
image.af.inflate()
return image
}
}
struct Content {
}
struct RowView:View {
var content:Content
var body: some View{
HStack{
Text("vvv")
}
}
}
struct IndexView: View {
@State var icon: String="arrowbottom"
var body: some View {
VStack {
TopView(icon: $icon)
// RowView()
Spacer()
}
}
}
struct IndexView_Previews: PreviewProvider {
static var previews: some View {
IndexView()
}
}