-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1c42a0
commit 523f8ce
Showing
3 changed files
with
39 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,53 @@ | ||
export const generateSwiftUIReadmeFile = (fileName: string): string => { | ||
export const generateSwiftUIReadmeFile = (): string => { | ||
return `# How to use the theme | ||
1. Move the \`theme\` directory into your project | ||
2. Replace the string \`replace.\` inside the \`theme\` directory with your package name for example: \`com.example.myapplication.\` | ||
3. Add your theme to the MainActivity: | ||
3. Add your theme to your \`ContentView\`: | ||
\`\`\`\` kotlin | ||
import com.example.myapplication.theme.${fileName} | ||
... | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContent { | ||
${fileName} { | ||
//... your content | ||
} | ||
import SwiftUI | ||
@main | ||
struct YourApp: App { | ||
var body: some Scene { | ||
WindowGroup { | ||
ContentView() | ||
.dsTheme() | ||
} | ||
} | ||
} | ||
\`\`\`\` | ||
Use the tokens like this: | ||
\`\`\`\` kotlin | ||
Text( | ||
text = "Headline", | ||
style = DBTheme.typography.h1, | ||
color = DBTheme.colors.neutral.onBgBasicEmphasis100, | ||
modifier = Modifier.padding(DBTheme.dimensions.spacing.fixedMd) | ||
) | ||
\`\`\`\` swift | ||
struct ContentView: View { | ||
@Environment(\\.theme) var theme | ||
@State var scheme: DSColorVariant? | ||
var body: some View { | ||
Text("Headline") | ||
.font(theme.fonts.h1.font) | ||
.foregroundColor(theme.activeColor.onBgBasicEmphasis80Default) | ||
.padding(theme.dimensions.spacing.responsiveXs) | ||
} | ||
} | ||
\`\`\`\` | ||
## Fonts | ||
To use another theme, export it and copy the \`theme/<theme name>\` directory to your project. Set it like this: | ||
[Download](https://marketingportal.extranet.deutschebahn.com/marketingportal/Design-Anwendungen/db-ux-design-system/version-2/foundation/Typografie) fonts and use the \`.ttf\` files. | ||
You might rename it based on the names in \`~/theme/data/Fonts.kt\` and move the \`.ttf\` files into \`~/res/font\` folder. | ||
\`\`\`swift | ||
// Code from step 3 | ||
@main | ||
struct YourApp: App { | ||
var body: some Scene { | ||
WindowGroup { | ||
ContentView() | ||
.dsTheme(<theme name>Theme()) | ||
} | ||
} | ||
} | ||
\`\`\` | ||
`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters