bitrig
EARLY ACCESS

Shared Project

Open in bitrigDownload Code
import SwiftUI
import Foundation

@main
struct BitrigDocsApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

struct ContentView: View {
    @State private var selectedTab = 0
    
    var body: some View {
        TabView(selection: $selectedTab) {
            DocumentationView()
                .tabItem {
                    Image(systemName: "doc.text")
                    Text("Docs")
                }
                .tag(0)
            
            RSSFeedView()
                .tabItem {
                    Image(systemName: "newspaper")
                    Text("News")
                }
                .tag(1)
        }
    }
}

struct DocumentationView: View {
    var body: some View {
        NavigationStack {
            ScrollView {
                VStack(alignment: .leading, spacing: 20) {
                    HStack {
                        Image(systemName: "sparkles")
                            .font(.largeTitle)
                            .foregroundColor(.blue)
                        
                        VStack(alignment: .leading) {
                            Text("Bitrig")
                                .font(.largeTitle)
                                .fontWeight(.bold)
                            Text("Advanced Code Generator")
                                .font(.subheadline)
                                .foregroundColor(.secondary)
                        }
                        
                        Spacer()
                    }
                    .padding()
                    .background(Color.blue.opacity(0.1))
                    .cornerRadius(12)
                    
                    VStack(alignment: .leading, spacing: 16) {
                        DocSection(
                            title: "What is Bitrig?",
                            content: "Bitrig is an advanced code generator for building SwiftUI iPhone apps. It helps developers create high-quality iOS applications through intelligent code generation and best practices enforcement."
                        )
                        
                        DocSection(
                            title: "Key Features",
                            content: """
                            • Real-time SwiftUI code generation
                            • Apple design guidelines compliance
                            • Security best practices enforcement
                            • Modern iOS development patterns
                            • Intelligent error handling
                            """
                        )
                        
                        DocSection(
                            title: "Getting Started",
                            content: """
                            1. Describe your app idea in natural language
                            2. Bitrig generates optimized SwiftUI code
                            3. See live preview of your app
                            4. Iterate and refine with additional prompts
                            """
                        )
                        
                        DocSection(
                            title: "Best Practices",
                            content: """
                            • Use NavigationStack for navigation
                            • Follow Apple's Human Interface Guidelines
                            • Implement proper state management
                            • Ensure accessibility compliance
                            • Optimize for different screen sizes
                            """
                        )
                        
                        DocSection(
                            title: "The Team",
                            content: """
                            Kyle Macomber - Co-founder, CEO (@kylemacomber)
                            Jacob Xiao - Co-founder, Engineering (@jacobx)
                            Tim Donnelly - Co-founder, Design (@tdonnelly)
                            
                            Kyle and Jacob are co-creators of SwiftUI and led development of the framework at Apple for over 10 years. Kyle managed the Swift Standard Library while Jacob worked on UIKit and Xcode.
                            
                            Tim co-founded Storehouse (Apple Design Award winner, acquired by Square) and worked on SwiftUI Previews at Apple.
                            """
                        )
                        
                        DocSection(
                            title: "Support",
                            content: "For support and updates, visit bitrig.app or check the latest news in the News tab for community discussions and announcements."
                        )
                    }
                }
                .padding()
            }
            .navigationTitle("Documentation")
        }
    }
}

struct DocSection: View {
    let title: String
    let content: String
    
    var body: some View {
        VStack(alignment: .leading, spacing: 8) {
            Text(title)
                .font(.headline)
                .foregroundColor(.primary)
            
            Text(content)
                .font(.body)
                .foregroundColor(.secondary)
        }
        .padding()
        .background(Color.gray.opacity(0.1))
        .cornerRadius(8)
    }
}

struct RSSFeedView: View {
    @State private var feedItems: [FeedItem] = []
    @State private var isLoading = false
    @State private var searchQuery = ""
    
    private let feedSources = [
        "https://news.google.com/rss/search?q=bitrig.app",
        "https://feeds.feedburner.com/hacker-news-feed-200",
        "https://rss.cnn.com/rss/edition.rss"
    ]
    
    var filteredItems: [FeedItem] {
        if searchQuery.isEmpty {
            return feedItems
        }
        return feedItems.filter { item in
            item.title.localizedCaseInsensitiveContains(searchQuery) ||
            item.description.localizedCaseInsensitiveContains(searchQuery)
        }
    }
    
    var body: some View {
        NavigationStack {
            ScrollView {
                VStack(spacing: 16) {
                    SearchBar(searchQuery: $searchQuery)
                    
                    if isLoading {
                        ProgressView("Loading feeds...")
                            .frame(maxWidth: .infinity, maxHeight: .infinity)
                            .padding(50)
                    } else {
                        LazyVStack(spacing: 12) {
                            ForEach(filteredItems) { item in
                                FeedItemView(item: item)
                            }
                        }
                        .padding(.horizontal)
                    }
                }
            }
            .navigationTitle("Bitrig News")
            .refreshable {
                loadFeeds()
            }
            .onAppear {
                if feedItems.isEmpty {
                    loadFeeds()
                }
            }
        }
    }
    
    private func loadFeeds() {
        isLoading = true
        var allItems: [FeedItem] = []
        let group = DispatchGroup()
        
        // Add sample items simulating Hacker News and Google searches for bitrig.app
        DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
            allItems = [
                FeedItem(
                    id: UUID(),
                    title: "[HN] SwiftUI co-creators launch Bitrig.app",
                    description: "Kyle Macomber and Jacob Xiao, who led SwiftUI development at Apple, announce their new code generation platform for iOS apps.",
                    link: "https://news.ycombinator.com/item?id=12345678",
                    pubDate: Date().addingTimeInterval(-1800)
                ),
                FeedItem(
                    id: UUID(),
                    title: "[Google] Former Apple engineers behind SwiftUI start Bitrig",
                    description: "Kyle Macomber (Swift Standard Library) and Jacob Xiao (UIKit, Xcode) team up with Tim Donnelly (Storehouse, SwiftUI Previews) to revolutionize iOS development.",
                    link: "https://techcrunch.com/bitrig-swiftui-creators",
                    pubDate: Date().addingTimeInterval(-3600)
                ),
                FeedItem(
                    id: UUID(),
                    title: "[HN] Ask HN: Thoughts on Bitrig by SwiftUI creators?",
                    description: "The team that built SwiftUI at Apple just launched bitrig.app. Given their track record with frameworks, this could be huge for iOS development.",
                    link: "https://news.ycombinator.com/item?id=12345679",
                    pubDate: Date().addingTimeInterval(-7200)
                ),
                FeedItem(
                    id: UUID(),
                    title: "[Google] Tim Donnelly joins Bitrig as design co-founder",
                    description: "Apple Design Award winner and former SwiftUI Previews engineer Tim Donnelly (@tdonnelly) brings his expertise to the Bitrig team.",
                    link: "https://9to5mac.com/tim-donnelly-bitrig",
                    pubDate: Date().addingTimeInterval(-10800)
                ),
                FeedItem(
                    id: UUID(),
                    title: "[HN] Show HN: Built with Bitrig - SwiftUI best practices built-in",
                    description: "Used bitrig.app for my latest iOS project. The code quality is exceptional - makes sense given Kyle and Jacob literally created SwiftUI.",
                    link: "https://news.ycombinator.com/item?id=12345680",
                    pubDate: Date().addingTimeInterval(-14400)
                ),
                FeedItem(
                    id: UUID(),
                    title: "[Google] Jacob Xiao discusses Bitrig's engineering philosophy",
                    description: "Former UIKit and Xcode engineer Jacob Xiao (@jacobx) explains how Bitrig applies lessons learned from building developer tools at Apple.",
                    link: "https://arstechnica.com/jacob-xiao-bitrig-interview",
                    pubDate: Date().addingTimeInterval(-18000)
                ),
                FeedItem(
                    id: UUID(),
                    title: "[HN] Kyle Macomber on the future of iOS development",
                    description: "SwiftUI co-creator and former Swift Standard Library manager Kyle Macomber (@kylemacomber) shares his vision for automated app development.",
                    link: "https://news.ycombinator.com/item?id=12345681",
                    pubDate: Date().addingTimeInterval(-21600)
                )
            ]
            
            self.feedItems = allItems.sorted { $0.pubDate > $1.pubDate }
            self.isLoading = false
        }
    }
}

struct SearchBar: View {
    @Binding var searchQuery: String
    
    var body: some View {
        HStack {
            Image(systemName: "magnifyingglass")
                .foregroundColor(.gray)
            
            TextField("Search news...", text: $searchQuery)
                .textFieldStyle(PlainTextFieldStyle())
            
            if !searchQuery.isEmpty {
                Button(action: { searchQuery = "" }) {
                    Image(systemName: "xmark.circle.fill")
                        .foregroundColor(.gray)
                }
            }
        }
        .padding(12)
        .background(Color.gray.opacity(0.1))
        .cornerRadius(8)
        .padding(.horizontal)
    }
}

struct FeedItemView: View {
    let item: FeedItem
    
    var body: some View {
        VStack(alignment: .leading, spacing: 8) {
            Text(item.title)
                .font(.headline)
                .foregroundColor(.primary)
                .multilineTextAlignment(.leading)
            
            Text(item.description)
                .font(.body)
                .foregroundColor(.primary)
                .opacity(0.8)
                .lineLimit(3)
            
            HStack {
                Text(item.pubDate, style: .relative)
                    .font(.caption)
                    .foregroundColor(.primary)
                    .opacity(0.6)
                
                Spacer()
                
                Button("Read More") {
                    // In a real app, would open the link
                }
                .font(.caption)
                .foregroundColor(.accentColor)
                .fontWeight(.medium)
            }
        }
        .padding()
        .background(Color(.systemBackground))
        .overlay(
            RoundedRectangle(cornerRadius: 8)
                .stroke(Color(.systemGray4), lineWidth: 0.5)
        )
        .cornerRadius(8)
    }
}

struct FeedItem: Identifiable, Codable {
    let id: UUID
    let title: String
    let description: String
    let link: String
    let pubDate: Date
}