Skip to content

iOS Development

Shaban Kamel edited this page Sep 20, 2024 · 1 revision

iOS Development

Resources

In ContentView.swift, you can show the logo like this example:

struct HeaderView: View {
    var body: some View {
        Image("logo")
            .resizable()
            .aspectRatio(contentMode: .fit)
            .frame(height: 200)
    }
}

The logo is copied to Assets.xcassets/SolaraArtifacts/logo.imageasset during the switching process. If you change the logo for different brands, it will automatically display the appropriate image.

Theme

To apply the brand theme, write something like this example:

struct ContentView: View {
    var body: some View {
        NavigationView {
            MyHomePage(title: "Infinite")
        }
        .accentColor(BrandTheme.Colors.primary)
        .background(BrandTheme.Colors.background)
    }
}

Each color is referenced from BrandTheme.Colors, which is generated by Solara during the switching process.

App Configurations

Solara simplifies accessing app configurations by generating them for you. You can retrieve this data from BrandConfig.swift as shown below:

var body: some View {
    VStack(alignment: .leading, spacing: 8) {
        InfoText(title: "Bundle Identifier:", value: brandConfig.bundleIdentifier)
        InfoText(title: "Version Name:", value: brandConfig.marketingVersion)
        InfoText(title: "Build Number:", value: String(brandConfig.bundleVersion))
    }
}

Custom Configurations

To add custom configurations for each brand, place the configuration in YOUR_BRAND/shared/brand_config. For example, you might have:

  • Brand 1 (brand_config.json)
{
    "showSplashScreen": true,
    "baseUrl": "https://www.google.com"
}
  • Brand 2 (brand_config.json)
{
    "showSplashScreen": false,
    "baseUrl": "https://www.facebook.com"
}

To access these configurations, we call BrandConfig.instance:

var body: some View {
    VStack(alignment: .leading, spacing: 8) {
        InfoText(title: "baseUrl:", value: brandConfig.baseUrl)
        InfoText(title: "showSplashScreen:", value: String(brandConfig.showSplashScreen))
    }
}

For the full project, check the Infinite iOS Project.

Clone this wiki locally