Skip to content

简单干货集中营的SwiftUI版本。网络请求用的Moya/RxSwift,网络请求回来的数据通过SwiftUI展示,SwiftUI网格视图用的第三方实现的。学习完官网的SwiftUI tutorials后的第一个实践项目

Notifications You must be signed in to change notification settings

Insfgg99x/GeekMadeBySwiftUI

Repository files navigation

GeekMadeBySwiftUI

干货集中营SwiftUI版

var body: some View {
    NavigationView {
        List {
            PageView(vm.banners.map { KFImage(URL(string: $0)) })
                .scaledToFill()
                .frame(height: sw * 0.6)
                .clipped()
                .listRowInsets(EdgeInsets())
            ForEach((0..<vm.data.count), id : \.self) { index in
                Section(header:
                    VStack(alignment: .leading) {
                        Text(self.vm.data[index].category)
                        .font(.headline)
                        .bold()
                        .frame(height : 25)
                        .padding(.leading, 15)
                        .offset(x: 0, y: 5)
                        Divider()
                    }
                    .background(Color.white)
                ) {
                    ForEach(self.vm.data[index].feeds) { feed in
                        NavigationLink(destination: FeedDetail(feed: feed)) {
                            FeedView(feed: feed)
                        }
                        .padding(.trailing, -16)//hide accosryView(arrow)
                    }
                }
            }
            .listRowInsets(EdgeInsets())
        }
        .navigationBarTitle("Today", displayMode: .inline)
    }
var body: some View {
    NavigationView {
        VStack {
            Picker("type", selection: $vm.type) {
                ForEach(Feed.FeedType.allCases, id: \.self) {
                    Text($0.rawValue)
                        .tag($0)
                        .font(.system(size: 8))
                }
            }
            .pickerStyle(SegmentedPickerStyle())
            .padding(.leading, 10)
            .padding(.trailing, 10)
            .padding(.top, 10)
            if vm.type == .welfare {
                ImageContainer()
                    .padding(10)
                    .environmentObject(vm)
            } else {
                List(vm.feeds) { feed in
                    NavigationLink(destination: FeedDetail(feed: feed)) {
                        FeedView(feed: feed)
                    }
                }
                .listRowInsets(EdgeInsets())
            }
        }
        .navigationBarTitle("Category", displayMode: .inline)
    }
}

Mac截图

Category

Today

Favorites

Detail

iPhone截图

Category

Today

Grid

Me

Detail

About

简单干货集中营的SwiftUI版本。网络请求用的Moya/RxSwift,网络请求回来的数据通过SwiftUI展示,SwiftUI网格视图用的第三方实现的。学习完官网的SwiftUI tutorials后的第一个实践项目

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published