From 16a7fec1407843f254337fad7e2accff80b0aac7 Mon Sep 17 00:00:00 2001 From: hua <1029559041@qq.com> Date: Wed, 19 Aug 2020 05:06:45 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../edit.imageset/Contents.json | 21 ++ Weibo/Assets.xcassets/edit.imageset/edit.png | Bin 0 -> 763 bytes .../house.imageset/Contents.json | 21 ++ .../Assets.xcassets/house.imageset/house.png | Bin 0 -> 829 bytes .../red packet.imageset/Contents.json | 21 ++ .../red packet.imageset/red packet.png | Bin 0 -> 657 bytes .../user-search-line.imageset/Contents.json | 21 ++ .../user-search-line.png | Bin 0 -> 1202 bytes .../user.imageset/Contents.json | 21 ++ Weibo/Assets.xcassets/user.imageset/user.png | Bin 0 -> 1225 bytes Weibo/ContentView.swift | 11 +- Weibo/IndexView.swift | 202 +++++++++++++++--- 12 files changed, 292 insertions(+), 26 deletions(-) create mode 100644 Weibo/Assets.xcassets/edit.imageset/Contents.json create mode 100644 Weibo/Assets.xcassets/edit.imageset/edit.png create mode 100644 Weibo/Assets.xcassets/house.imageset/Contents.json create mode 100644 Weibo/Assets.xcassets/house.imageset/house.png create mode 100644 Weibo/Assets.xcassets/red packet.imageset/Contents.json create mode 100644 Weibo/Assets.xcassets/red packet.imageset/red packet.png create mode 100644 Weibo/Assets.xcassets/user-search-line.imageset/Contents.json create mode 100644 Weibo/Assets.xcassets/user-search-line.imageset/user-search-line.png create mode 100644 Weibo/Assets.xcassets/user.imageset/Contents.json create mode 100644 Weibo/Assets.xcassets/user.imageset/user.png diff --git a/Weibo/Assets.xcassets/edit.imageset/Contents.json b/Weibo/Assets.xcassets/edit.imageset/Contents.json new file mode 100644 index 0000000..c9c7d7d --- /dev/null +++ b/Weibo/Assets.xcassets/edit.imageset/Contents.json @@ -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 + } +} diff --git a/Weibo/Assets.xcassets/edit.imageset/edit.png b/Weibo/Assets.xcassets/edit.imageset/edit.png new file mode 100644 index 0000000000000000000000000000000000000000..5851f8cad0b9de0c3ff49267b9061486ff197d31 GIT binary patch literal 763 zcmVfh|y#;RGfZ$dIiE z+$l*gFXjnjt)NPy|Lb2Zb&HT;SmRn7%q*nqJHcqp37pJ|t+q>0wA zN*Q+XD}XkLN=frI4{rbrv9oVQ$CSS#M=XFfu6+aZm(;>R83{tv7smW9iXarg8dOTS zC{A39Q^g%KiA`+nMwlB%0MKqed@v;EvL6vn)BSR@<* zcfy!UJt%P(`Y%4UtxcVKSPp5|Nv;Co3;T@)4 z2o>P=^3lIO{}9Has{sCvsvBRjWFYa1I}ryUtWj+ULd&--^F}lmg4Fd23^HhXoOBZ| z_`N*N+6l7uS9h31hfcLWEb=3Wu*m&3+>j1H6Rz0U&V;UP>ImDrFKrH-xd2cY5eJ^&~+jVZtrQJOkk>s-7o) zADdu&pL7xZ5yrf%MQ{^@I8R)Wb&{@Pr)mWu&J~w=^}4wz#TTQCr)%-vT)S0m?*zjH zQ8(@J4WH*JMzUsep|}ndq?It{`?gyzkypE>PSwsX%g!jeA))76@p0MLrL@=rQ!l2d zWHrOzkhm6muVwB5=;qfMJB&VOkDAhut;iZ(k5m0j>ocRB7DNkUh^^f_>v0++*8L;5 t!6@%r_(LPJQZHhH3D8s+^I_Tz`ws-Pvv&574s`$k002ovPDHLkV1msg|p1dy2+%U6F=+u2>#d{aUFFjI~yDfX` zg|5UEg*$Ie#nd0ax0wCWhQ;vpS67oC{+8@r}WFX?U+Tzu{9jxr{TBX&` z{r>-dVnCBvm(8S#xOda%Og3>nkzG@F?kane0N3sc8ODYTop~NvOCsi_(kE@s zh-pm;|_WZ_Oc}%)} zeaO{!6UsnIMYY5=q9i4;B-JXpC>2OC7#SED=o(n)8d`=Jm{=K`Ss7bs8(3Hw7!(&S z4n)zAo1c=IR*72!laBOTpayr44aH^YR!ND)sk)^_nG9)}IjL6q`uZ99xvBbzDY=<> z`kBf3dAe!&c_sQKxdmWed|{D!u|bwem7xhxVQF!y9?*>EU&Y@8jb!k2^>bP0l+XkK D#I)BA literal 0 HcmV?d00001 diff --git a/Weibo/Assets.xcassets/red packet.imageset/Contents.json b/Weibo/Assets.xcassets/red packet.imageset/Contents.json new file mode 100644 index 0000000..0bb330d --- /dev/null +++ b/Weibo/Assets.xcassets/red packet.imageset/Contents.json @@ -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 + } +} diff --git a/Weibo/Assets.xcassets/red packet.imageset/red packet.png b/Weibo/Assets.xcassets/red packet.imageset/red packet.png new file mode 100644 index 0000000000000000000000000000000000000000..43c41e27735455e343211c2947e770bf3e6c6f9d GIT binary patch literal 657 zcmV;C0&e|@P);v>ggP75IX`|2 zz%w(Q0J;@(fJpBD0V`lKNt1Pccj1hL=M5>fTwaWTeg@Ck3G6+^!J@}q=0qt`VG+=j=BcG8u`)tv8GFd7aRfP zd!u0*IzP^a;R=Jue1*Pp`-JD-$OA_Jc4Q!=cXcK`$3tL`2axjTcVs~rV}M*Lohv`I z)dO%Duu>q_Aj^h5F$MAV{b6q+Ht86EEi0+JcEWpLFDTFo7NP_qB}hI2(`)ElX^aSy zL3$5Zg+NMy^Qt)G)w>k(Pp2UlG9bfP9{>qT7K>ZSLg#Y8_BK$954_n2qvr!yrom=u zJy32Ml=s6L-vKP7!JpHhY!<>aA)9?gAJ+V50F|16Pkw=DZvyMq5`f4+r&d9CD~@~j z0qnLpn0?#8%q0LK*zr%0^INMnt-A_n4ck8p*}Ym!s9$Y@cd4+stDCC;YiV?$(}_TZ z2CZTL1fW*Z^7{rrLxF|@8%qI>47MwwX4mtb*YcHGc2MGS%F#M5IN7HMhQSo771+@| r@uYV&HeAW~|Nb|0RNY@X)m?$_t`!lvI6;x#X;^) z4C~IxyacIC_6YK2V5m}KU}$JzVE6?TYIwoGP-?)y@G60U!Dmz)d#{>hL0x7e23ZfUr{o7eoM&Bcem z@$h~>`0CKh9~(D4y!c?1hSrLpUCes|7*DM^p*%TpilWZlJKD96YBW7`J*9norTjOn zQ$6DJu0A1ez5eIj9Fm;(`n<}Qy%)YB(RH9YWvZxo=*2^EtASQCCV9KNFm$lWdH^|` z1s;*bKpMpMU~oH`Z3k3P=IP=XVsUzEPA?i;Sj;@m>6$p@Lr zHkLpCzrRw&@>IE_{qv`3&aYd{_34`A`>qfnU7kUf$pHGbY!r7LQx=xhxdhv@p+Hjp*BIC*QnzwP=qxH?!-a_nWUSV4s=w z(;!kN&J0= z?bpo28)80wVTw9gz<%fRw>LbU8gg=#3xYk~biG!;kUsA-v;Na6K8BO8YnkG_SDGIP zG<#8)t@dT^a=V7}UDLkoIddhP>(uo}uYd2ZVhU${J9E$FoR&Xbd+ke@?HLY7Z&;iq z@evpmswJ)wB`Jv|saDBFsX&Us$iT=z*T6#8&@#lp$jZ>r%Gg5Nz{1MFAXDX@35tf? z{FKbJO57SGD$_cE8iGMK6qlu2B_$T8>XsH|GNfhZq+03g>u2QWrs^lA89o9mFSn`7Jzy2<;BS*Y2{{VndV9QrNya5y2Yu9MadbuIhlE>dO-6m0{2}98qeVA L>gTe~DWM4f!D>*k literal 0 HcmV?d00001 diff --git a/Weibo/Assets.xcassets/user.imageset/Contents.json b/Weibo/Assets.xcassets/user.imageset/Contents.json new file mode 100644 index 0000000..21d8882 --- /dev/null +++ b/Weibo/Assets.xcassets/user.imageset/Contents.json @@ -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 + } +} diff --git a/Weibo/Assets.xcassets/user.imageset/user.png b/Weibo/Assets.xcassets/user.imageset/user.png new file mode 100644 index 0000000000000000000000000000000000000000..f6cffaa8a65214e0143d5eb3d4a0f9eb022d5e3c GIT binary patch literal 1225 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyEa{HEjtmSN`?>!lvI6;x#X;^) z4C~IxyacIC_6YK2V5m}KU}$JzVE6?TYIwoGP-?)y@G60U!DXSiI;z3iicN{ zd)A$03EZ*M@$%Fck$RvD%fiWZ-|b8L$Avbm(JzL+r=EN4^1su2THh-v75#n|B z@jdmplX=A}1HtLforL;oG!^HH?b(;?!4+{PrD3&Cz%=C&CP}xVKbmvqE|%BRQ|yW> zW}Ua@%ZWA8>t5@znp@T^yQ6#O?_Qv8&6z){w|$FZtx$OTm&5<+%$@07E5wVRs#mp| z8-3t&-Ds6tXOys&@)+6ER@1_s52i%~V?=BH$)RpQpb zq$B+nXoDNbhT^hxtE9x@RNc~|Oop_~oK!1)ef^C5+*JL9-gzG*)6B#^R{an^LB{Ts56cbDk literal 0 HcmV?d00001 diff --git a/Weibo/ContentView.swift b/Weibo/ContentView.swift index dee98f3..bb57cd1 100644 --- a/Weibo/ContentView.swift +++ b/Weibo/ContentView.swift @@ -16,8 +16,15 @@ struct ContentView: View { var body: some View { TabView(selection: self.$selection) { - IndexView().tabItem { Text("首页") }.tag(1) - LoginView().tabItem { Text("我") }.tag(2) + IndexView().tabItem { VStack { + Image("house") + Text("首页") + .foregroundColor(Color.black) + } }.tag(1) + LoginView().tabItem { VStack { + Image("user") + Text("我") + } }.tag(2) } } } diff --git a/Weibo/IndexView.swift b/Weibo/IndexView.swift index 811762b..cb7417f 100644 --- a/Weibo/IndexView.swift +++ b/Weibo/IndexView.swift @@ -8,40 +8,103 @@ import SwiftUI 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 { @Binding var icon: String + @State var activeMenu:String="全部关注" + + @State var menuIndex=0 + var body: some View{ VStack { - HStack(alignment: .center){ - Button(action: { - if self.icon=="arrowbottom"{ - self.icon="arrowtop" - }else{ - self.icon="arrowbottom" + HStack { + Image("user-search-line") + Spacer() + HStack{ + Button(action: { + if self.icon=="arrowbottom"{ + self.icon="arrowtop" + }else{ + self.icon="arrowbottom" + } + self.menuIndex=0 + }) { + HStack { + TextView(title: self.activeMenu, isActive: self.menuIndex==0) + Image(self.icon) + .padding(.leading, -9.0) + + } } - }) { - HStack { - Text("最新微博") - .foregroundColor(Color.black) - Image(self.icon) + Button(action: { + print("推荐") + self.menuIndex=1 + }){ + TextView(title: "推荐", isActive: self.menuIndex==1) + } + Button(action: { + print("同城") + self.menuIndex=2 + }){ + TextView(title: "同城", isActive: self.menuIndex==2) } } - Button(action: { - print("推荐") - }){ - Text("推荐") - .foregroundColor(Color.gray) - } - Button(action: { - print("同城") - }){ - Text("同城") - .foregroundColor(Color.gray) + Spacer() + HStack(){ + Image("red packet") + Image("edit") } + .padding(.trailing, 18.0) + .frame(width: nil) + } - if self.icon=="arrowtop"{ + + if self.icon=="arrowbottom"{ HStack { Text("默认分组") .foregroundColor(Color.gray) @@ -53,6 +116,97 @@ struct TopView:View { .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 { - @State var icon: String="arrowbottom" + @State var icon: String="arrowtop" var body: some View { VStack {