首页界面

master
hua 4 years ago
parent baeaabdd59
commit 16a7fec140
  1. 21
      Weibo/Assets.xcassets/edit.imageset/Contents.json
  2. BIN
      Weibo/Assets.xcassets/edit.imageset/edit.png
  3. 21
      Weibo/Assets.xcassets/house.imageset/Contents.json
  4. BIN
      Weibo/Assets.xcassets/house.imageset/house.png
  5. 21
      Weibo/Assets.xcassets/red packet.imageset/Contents.json
  6. BIN
      Weibo/Assets.xcassets/red packet.imageset/red packet.png
  7. 21
      Weibo/Assets.xcassets/user-search-line.imageset/Contents.json
  8. BIN
      Weibo/Assets.xcassets/user-search-line.imageset/user-search-line.png
  9. 21
      Weibo/Assets.xcassets/user.imageset/Contents.json
  10. BIN
      Weibo/Assets.xcassets/user.imageset/user.png
  11. 11
      Weibo/ContentView.swift
  12. 172
      Weibo/IndexView.swift

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "edit.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 763 B

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "house.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 829 B

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "red packet.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 657 B

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "user-search-line.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "user.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -16,8 +16,15 @@ struct ContentView: View {
var body: some View { var body: some View {
TabView(selection: self.$selection) { TabView(selection: self.$selection) {
IndexView().tabItem { Text("首页") }.tag(1) IndexView().tabItem { VStack {
LoginView().tabItem { Text("") }.tag(2) Image("house")
Text("首页")
.foregroundColor(Color.black)
} }.tag(1)
LoginView().tabItem { VStack {
Image("user")
Text("")
} }.tag(2)
} }
} }
} }

@ -8,40 +8,103 @@
import SwiftUI import SwiftUI
import AlamofireImage import AlamofireImage
struct ButtonView:View{
var title:String
var action:() -> Void
@Binding var activeMenu:String
func isActive(name:String)->Color{
if name==self.activeMenu{
return Color.orange
}else{
return Color.black
}
}
var body: some View{
Button(action: action) {
Text(title)
.foregroundColor(isActive(name: title))
}
.padding(.all, 10.0)
.frame(width: 90.0)
.background(Color(red: 222/255, green: 223/255, blue: 222/255, opacity: 1.0))
.clipShape(Rectangle())
.cornerRadius(3)
}
}
struct TextView:View {
var title:String
var isActive:Bool
var body: some View{
if isActive{
return Text(title)
.foregroundColor(Color.black)
.fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/)
}else{
return Text(title)
.foregroundColor(Color.gray)
}
}
}
struct TopView:View { struct TopView:View {
@Binding var icon: String @Binding var icon: String
@State var activeMenu:String="全部关注"
@State var menuIndex=0
var body: some View{ var body: some View{
VStack { VStack {
HStack(alignment: .center){ HStack {
Image("user-search-line")
Spacer()
HStack{
Button(action: { Button(action: {
if self.icon=="arrowbottom"{ if self.icon=="arrowbottom"{
self.icon="arrowtop" self.icon="arrowtop"
}else{ }else{
self.icon="arrowbottom" self.icon="arrowbottom"
} }
self.menuIndex=0
}) { }) {
HStack { HStack {
Text("最新微博") TextView(title: self.activeMenu, isActive: self.menuIndex==0)
.foregroundColor(Color.black)
Image(self.icon) Image(self.icon)
.padding(.leading, -9.0)
} }
} }
Button(action: { Button(action: {
print("推荐") print("推荐")
self.menuIndex=1
}){ }){
Text("推荐") TextView(title: "推荐", isActive: self.menuIndex==1)
.foregroundColor(Color.gray)
} }
Button(action: { Button(action: {
print("同城") print("同城")
self.menuIndex=2
}){ }){
Text("同城") TextView(title: "同城", isActive: self.menuIndex==2)
.foregroundColor(Color.gray)
} }
} }
if self.icon=="arrowtop"{ Spacer()
HStack(){
Image("red packet")
Image("edit")
}
.padding(.trailing, 18.0)
.frame(width: nil)
}
if self.icon=="arrowbottom"{
HStack { HStack {
Text("默认分组") Text("默认分组")
.foregroundColor(Color.gray) .foregroundColor(Color.gray)
@ -53,6 +116,97 @@ struct TopView:View {
.foregroundColor(Color.orange) .foregroundColor(Color.orange)
} }
} }
.padding(EdgeInsets(top: 5, leading: 20, bottom: 0, trailing: 20))
HStack(spacing: 10.0){
ButtonView(title: "全部关注", action: {
print("全部关注")
self.activeMenu="全部关注"
self.icon="arrowtop"
},activeMenu: self.$activeMenu)
ButtonView(title: "最新微博", action: {
print("最新微博")
self.activeMenu="最新微博"
self.icon="arrowtop"
},activeMenu: self.$activeMenu)
ButtonView(title: "特别关注", action: {
print("特别关注")
self.activeMenu="特别关注"
self.icon="arrowtop"
},activeMenu: self.$activeMenu)
ButtonView(title: "好友圈", action: {
print("好友圈")
self.activeMenu="好友圈"
self.icon="arrowtop"
},activeMenu: self.$activeMenu)
}
.padding(.top, 10.0)
HStack(spacing: 10.0){
ButtonView(title: "原创", action: {
print("原创")
self.activeMenu="原创"
self.icon="arrowtop"
},activeMenu: self.$activeMenu)
ButtonView(title: "视频", action: {
print("视频")
self.activeMenu="视频"
self.icon="arrowtop"
},activeMenu: self.$activeMenu)
ButtonView(title: "V+微博", action: {
print("V+微博")
self.activeMenu="V+微博"
self.icon="arrowtop"
},activeMenu: self.$activeMenu)
ButtonView(title: "群微博", action: {
print("群微博")
self.activeMenu="群微博"
self.icon="arrowtop"
},activeMenu: self.$activeMenu)
}
.padding(.top, 10.0)
HStack {
Text("我的分组")
.foregroundColor(Color.gray)
.padding(.leading, 20.0)
Spacer()
}
.padding(.top, 10.0)
HStack(spacing: 10.0){
ButtonView(title: "名人明星", action: {
print("名人明星")
self.activeMenu="名人明星"
self.icon="arrowtop"
},activeMenu: self.$activeMenu)
ButtonView(title: "同事", action: {
print("同事")
self.activeMenu="同事"
self.icon="arrowtop"
},activeMenu: self.$activeMenu)
ButtonView(title: "同学", action: {
print("同学")
self.activeMenu="同学"
self.icon="arrowtop"
},activeMenu: self.$activeMenu)
ButtonView(title: "悄悄关注", action: {
print("悄悄关注")
self.activeMenu="悄悄关注"
self.icon="arrowtop"
},activeMenu: self.$activeMenu)
}
.padding(.top, 10.0)
HStack(){
Button(action: /*@START_MENU_TOKEN@*/{}/*@END_MENU_TOKEN@*/) {
Text("+新建分组")
}
.foregroundColor(Color.black)
.padding(10.0)
.frame(width: 100.0)
.overlay(Rectangle()
.stroke(Color.gray, style: StrokeStyle(lineWidth: 2, dash: [5])))
Spacer()
}
.padding(10.0)
} }
} }
} }
@ -88,7 +242,7 @@ struct RowView:View {
struct IndexView: View { struct IndexView: View {
@State var icon: String="arrowbottom" @State var icon: String="arrowtop"
var body: some View { var body: some View {
VStack { VStack {

Loading…
Cancel
Save