mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-04-18 23:10:00 +02:00
Add Jike
This commit is contained in:
71
Examples/Jike/SwiftUI_Jike/Cell/ActivityCell.swift
Executable file
71
Examples/Jike/SwiftUI_Jike/Cell/ActivityCell.swift
Executable file
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// ActivityCell.swift
|
||||
// SwiftUI_Jike
|
||||
//
|
||||
// Created by alexyang on 2019/6/5.
|
||||
// Copyright © 2019 alexyang. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ActivityCell : View {
|
||||
var nickName:String
|
||||
var timeStamp:String
|
||||
var content:String
|
||||
var imgName:String
|
||||
var body: some View {
|
||||
VStack(alignment: .leading){
|
||||
HStack(){
|
||||
VStack{
|
||||
CircleImage(imgName: "pokemon")
|
||||
.padding(.leading, 20)
|
||||
.padding(.top, 10)
|
||||
Spacer()
|
||||
}
|
||||
|
||||
VStack(alignment: .leading){
|
||||
HStack{
|
||||
Text(nickName)
|
||||
.padding(.top, 5)
|
||||
.padding(.bottom, 2)
|
||||
Spacer()
|
||||
}
|
||||
Text(timeStamp)
|
||||
.font(Font.system(size: 12))
|
||||
.color(Color.gray)
|
||||
.padding(.bottom, 2)
|
||||
|
||||
Text(content)
|
||||
.frame(minHeight:50, maxHeight: 300, alignment: .top)
|
||||
.font(Font.system(size: 15))
|
||||
.lineLimit(-1)
|
||||
Image(imgName)
|
||||
.padding(.bottom, 20)
|
||||
.padding(.trailing, 10)
|
||||
}
|
||||
|
||||
}
|
||||
HStack{
|
||||
Spacer()
|
||||
Image("dianzan")
|
||||
Spacer()
|
||||
Image("pinglun")
|
||||
Spacer()
|
||||
Image("share")
|
||||
Spacer()
|
||||
Image("shenglue")
|
||||
}
|
||||
}
|
||||
.lineSpacing(0)
|
||||
.frame(minHeight: 300)
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct ActivityCell_Previews : PreviewProvider {
|
||||
static var previews: some View {
|
||||
ActivityCell(nickName: "皮卡丘", timeStamp: "2小时前",content: "发明一种新吃法#一人食灌蛋手抓饼夹小油条泡菜香肠,挤上番茄酱甜面酱巨好吃呀😘!!灌蛋是灵魂,不能偷懒!!", imgName: "sucai"
|
||||
)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
60
Examples/Jike/SwiftUI_Jike/Cell/CategoryRow.swift
Executable file
60
Examples/Jike/SwiftUI_Jike/Cell/CategoryRow.swift
Executable file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
See LICENSE folder for this sample’s licensing information.
|
||||
|
||||
Abstract:
|
||||
A view showing a scrollable list of landmarks.
|
||||
*/
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct CategoryRow: View {
|
||||
var items: [ZoneModel]
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
ScrollView(showsHorizontalIndicator: false) {
|
||||
HStack(alignment: .top, spacing: 0) {
|
||||
ForEach(self.items.identified(by: \.id)) { zone in
|
||||
CategoryItem(zone: zone)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct CategoryItem: View {
|
||||
var zone: ZoneModel
|
||||
var body: some View {
|
||||
VStack(alignment: .center) {
|
||||
|
||||
VStack{
|
||||
Color.white
|
||||
.frame(width:65,height:65)
|
||||
.border(Color(red: 218.0/255.0, green: 218.0/255.0, blue: 218.0/255.0),width: 3,cornerRadius: 15)
|
||||
.cornerRadius(15)
|
||||
zone
|
||||
.image(forSize: 55)
|
||||
.renderingMode(.original)
|
||||
.cornerRadius(10)
|
||||
.padding(.top,-68)
|
||||
|
||||
}
|
||||
Text(zone.name)
|
||||
.frame(width: 65, height: 20, alignment: .center)
|
||||
.font(Font.system(size: 12))
|
||||
.padding(.top, -8)
|
||||
}
|
||||
.padding(.trailing, -5)
|
||||
.padding(.leading, 10)
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct CategoryRow_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
|
||||
CategoryRow(items: zonnData)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
40
Examples/Jike/SwiftUI_Jike/Cell/ChatCell.swift
Executable file
40
Examples/Jike/SwiftUI_Jike/Cell/ChatCell.swift
Executable file
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// ChatCell.swift
|
||||
// SwiftUI_Jike
|
||||
//
|
||||
// Created by alexyang on 2019/6/5.
|
||||
// Copyright © 2019 alexyang. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ChatCell : View {
|
||||
var imageName:String
|
||||
var title:String
|
||||
var subTitle:String
|
||||
var body: some View {
|
||||
HStack(alignment: .center){
|
||||
CircleImage(imgName:imageName)
|
||||
VStack(alignment: .leading){
|
||||
Text(title)
|
||||
.bold()
|
||||
.padding(.top, 4)
|
||||
Text(subTitle)
|
||||
.color(Color.gray)
|
||||
.padding(.bottom, 8)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
.padding(.horizontal, 15)
|
||||
.frame(height: 60)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct ChatCell_Previews : PreviewProvider {
|
||||
static var previews: some View {
|
||||
ChatCell(imageName: "chat_box",title: "一条虫",subTitle: "瓦恁出来挨打")
|
||||
}
|
||||
}
|
||||
#endif
|
||||
27
Examples/Jike/SwiftUI_Jike/Cell/CircleImage.swift
Executable file
27
Examples/Jike/SwiftUI_Jike/Cell/CircleImage.swift
Executable file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
See LICENSE folder for this sample’s licensing information.
|
||||
|
||||
Abstract:
|
||||
A view that clips an image to a circle and adds a stroke and shadow.
|
||||
*/
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct CircleImage: View {
|
||||
var imgName:String
|
||||
var body: some View {
|
||||
Image(imgName)
|
||||
.clipShape(Circle())
|
||||
.overlay(
|
||||
|
||||
Circle().stroke(Color.white, lineWidth: 1))
|
||||
|
||||
.shadow(radius: 3)
|
||||
}
|
||||
}
|
||||
|
||||
struct CircleImage_Preview: PreviewProvider {
|
||||
static var previews: some View {
|
||||
CircleImage(imgName:"meIcon")
|
||||
}
|
||||
}
|
||||
51
Examples/Jike/SwiftUI_Jike/Cell/GYSegmentView.swift
Executable file
51
Examples/Jike/SwiftUI_Jike/Cell/GYSegmentView.swift
Executable file
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// GYSegmentView.swift
|
||||
// Landmarks
|
||||
//
|
||||
// Created by alexyang on 2019/6/6.
|
||||
// Copyright © 2019 Apple. All rights reserved.
|
||||
//
|
||||
import UIKit
|
||||
import SwiftUI
|
||||
|
||||
struct GYSegmentView : UIViewRepresentable {
|
||||
func makeCoordinator() -> GYSegmentView.Coordinator {
|
||||
Coordinator(self)
|
||||
}
|
||||
|
||||
|
||||
var titles:[String]
|
||||
@Binding var currentPage: Int
|
||||
|
||||
func makeUIView(context: Context) -> UISegmentedControl
|
||||
{
|
||||
let segment = UISegmentedControl(items: titles)
|
||||
segment.addTarget(context.coordinator, action:#selector(Coordinator.updateCurrentPage(sender:)) , for: .valueChanged)
|
||||
return segment
|
||||
}
|
||||
|
||||
func updateUIView(_ segment: UISegmentedControl, context: Context) {
|
||||
|
||||
segment.selectedSegmentIndex = currentPage
|
||||
}
|
||||
|
||||
class Coordinator: NSObject {
|
||||
var control: GYSegmentView
|
||||
|
||||
init(_ control: GYSegmentView) {
|
||||
self.control = control
|
||||
}
|
||||
|
||||
@objc func updateCurrentPage(sender: UISegmentedControl) {
|
||||
control.currentPage = sender.selectedSegmentIndex
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct GYSegmentView_Previews : PreviewProvider {
|
||||
static var previews: some View {
|
||||
GYSegmentView(titles: ["哈哈","你好","无聊"], currentPage: .constant(0))
|
||||
}
|
||||
}
|
||||
#endif
|
||||
92
Examples/Jike/SwiftUI_Jike/Cell/HomeCell.swift
Executable file
92
Examples/Jike/SwiftUI_Jike/Cell/HomeCell.swift
Executable file
@@ -0,0 +1,92 @@
|
||||
//
|
||||
// HomeCell.swift
|
||||
// SwiftUI_Jike
|
||||
//
|
||||
// Created by alexyang on 2019/6/6.
|
||||
// Copyright © 2019 alexyang. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct HomeCell : View {
|
||||
var zoneName:String
|
||||
var zoneImgName:String
|
||||
var userIcon:String
|
||||
var nickName:String
|
||||
var timeStamp:String
|
||||
var content:String
|
||||
var imgName:String
|
||||
var body: some View {
|
||||
VStack(alignment: .leading){
|
||||
VStack(){
|
||||
|
||||
HStack{
|
||||
ImageStore.shared.image(name: zoneImgName, size: 60)
|
||||
.cornerRadius(5)
|
||||
.padding(.leading, 20)
|
||||
.padding(.top, 10)
|
||||
.padding(.bottom, 10)
|
||||
VStack(alignment: .leading, spacing: 5){
|
||||
Text(zoneName)
|
||||
.font(Font.system(size: 16))
|
||||
.bold()
|
||||
Text(timeStamp)
|
||||
.font(Font.system(size: 12))
|
||||
.color(Color.gray)
|
||||
.padding(.top, 8)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
.background(Color(red: 245.0/255.0, green: 245.0/255.0, blue: 245.0/255.0))
|
||||
|
||||
VStack(alignment: .leading){
|
||||
Text(content)
|
||||
.font(Font.system(size: 15))
|
||||
.frame(minWidth: 320,minHeight:50, maxHeight: 300, alignment: .leading)
|
||||
.lineLimit(-1)
|
||||
ImageStore.shared.image(name: imgName, size: 200)
|
||||
.padding(.bottom, 10)
|
||||
}
|
||||
.padding(.leading, -20)
|
||||
|
||||
HStack(alignment: .center){
|
||||
CircleImage(imgName: userIcon)
|
||||
.padding(.leading, 20)
|
||||
Text(nickName)
|
||||
.font(Font.system(size: 14))
|
||||
.bold()
|
||||
Text("发布")
|
||||
.font(Font.system(size: 13))
|
||||
.color(Color.gray)
|
||||
Spacer()
|
||||
}
|
||||
|
||||
}
|
||||
Divider()
|
||||
.padding(.horizontal,20)
|
||||
HStack{
|
||||
Image("dianzan")
|
||||
Spacer()
|
||||
Image("pinglun")
|
||||
Spacer()
|
||||
Image("share")
|
||||
Spacer()
|
||||
Image("shenglue")
|
||||
}
|
||||
.padding(.leading, 20)
|
||||
.padding(.trailing, 20)
|
||||
Color(red: 240.0/255.0, green: 243.0/255.0, blue: 245.0/255.0)
|
||||
.frame(height: CGFloat(1.0))
|
||||
}
|
||||
.frame(height:450)
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct HomeCell_Previews : PreviewProvider {
|
||||
static var previews: some View {
|
||||
HomeCell(zoneName: "人人都爱宝可梦", zoneImgName: "30_Fotor", userIcon: "pokemon", nickName: "皮卡丘", timeStamp: "2小时前",content: "蒜头丘!\n皮卡皮卡₍₍ (̨̡ ‾᷄ᗣ‾᷅ )̧̢ ₎₎", imgName: "kcc"
|
||||
)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
38
Examples/Jike/SwiftUI_Jike/Cell/SettingCell.swift
Executable file
38
Examples/Jike/SwiftUI_Jike/Cell/SettingCell.swift
Executable file
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// SettingCell.swift
|
||||
// SwiftUI_Jike
|
||||
//
|
||||
// Created by alexyang on 2019/6/5.
|
||||
// Copyright © 2019 alexyang. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SettingCell : View {
|
||||
var imageName:String
|
||||
var title:String
|
||||
var body: some View {
|
||||
VStack{
|
||||
HStack(){
|
||||
Image(imageName)
|
||||
Text(title)
|
||||
Spacer()
|
||||
}
|
||||
.padding(.top, 5)
|
||||
.frame(height: 44)
|
||||
.padding(.horizontal, 15)
|
||||
Spacer()
|
||||
Color(red: 240.0/255.0, green: 243.0/255.0, blue: 245.0/255.0)
|
||||
.frame(height: 1)
|
||||
}
|
||||
.frame(height: 50)
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct SettingCell_Previews : PreviewProvider {
|
||||
static var previews: some View {
|
||||
SettingCell(imageName: "setting_quanzi", title: "我的圈子")
|
||||
}
|
||||
}
|
||||
#endif
|
||||
32
Examples/Jike/SwiftUI_Jike/Cell/ZoneCell.swift
Executable file
32
Examples/Jike/SwiftUI_Jike/Cell/ZoneCell.swift
Executable file
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// ZoneCell.swift
|
||||
// SwiftUI_Jike
|
||||
//
|
||||
// Created by alexyang on 2019/6/5.
|
||||
// Copyright © 2019 alexyang. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ZoneCell : View {
|
||||
var imgName:String
|
||||
var title:String
|
||||
var body: some View {
|
||||
VStack{
|
||||
Image(imgName)
|
||||
Text(title)
|
||||
.font(Font.system(size: 10))
|
||||
.color(Color.gray)
|
||||
.frame(alignment: .center)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct ZoneCell_Previews : PreviewProvider {
|
||||
static var previews: some View {
|
||||
ZoneCell(imgName: "pokemon", title: "苹果产品爱好者")
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user