diff --git a/README.md b/README.md index 6ecd1c6..7999501 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,97 @@ # FontPicker -A description of this package. +A Font Picker in a similar style to Apple's Color Picker, providing a means of choosing a font from the available UIFont familyNames. I'm not 100% sure that all of these font names work in SwiftUI, but they seem to. + +Example 1 + +## Installation + +### Swift Package Manager + +In Xcode: +* File ⭢ Swift Packages ⭢ Add Package Dependency... +* Use the URL https://github.com/franklynw/FontPicker + + +## Example + +> **NB:** All examples require `import FontPicker` at the top of the source file + +It can be used directly as a view, which offers the full range of customisation options - + +```swift +var body: some View { + + FontPicker(isPresented: $isFontPickerPresented, selected: $viewModel.selectedFont) + .additionalFontNames(["MySpecialFont"]) + .excludedFontNames(["Marker Felt"]) + .backgroundColor(viewModel.fontPickerBackgroundColor) +} +``` + +or as a modifier, which presents the default font picker (with no customisation options) - + +```swift +var body: some View { + + MyView { + + } + .fontPicker(isPresented: $isFontPickerPresented, Binding: $viewModel.selectedFont) { + // your view here + } +} +``` + +### Specify the fonts you want to be shown + +If you use this modifier, it will only show the fonts you specify + +```swift +FontPicker(isPresented: $isFontPickerPresented, selected: $viewModel.selectedFont) + .fontNames(viewModel.allTheBestFonts) +``` + +### Specify the fonts you'd like to add to the default list + +This will show all of the available system fonts, plus any you pass in here + +```swift +FontPicker(isPresented: $isFontPickerPresented, selected: $viewModel.selectedFont) + .additionalFontNames(viewModel.myUniqueFonts) +``` + +### Specify the fonts you'd like to not be shown + +This will show all of the available system fonts, minus any you pass in here + +```swift +FontPicker(isPresented: $isFontPickerPresented, selected: $viewModel.selectedFont) + .excludedFontNames(viewModel.rubbishFonts) +``` + +### Disable the automatic "dismiss on selection" functionality + +This might be necessary if you have (eg) a preview visible above the picker, where you can see how your selected font looks - the user can then decide when to dismiss the picker + +```swift +FontPicker(isPresented: $isFontPickerPresented, selected: $viewModel.selectedFont) + .disableDismissOnSelection +``` + +### Set the picker's background colour + +```swift +FontPicker(isPresented: $isFontPickerPresented, selected: $viewModel.selectedFont) + .backgroundColor(.lightGray) +``` + + +## Dependencies + +Requires HalfASheet, which is linked. Take a look at it [here](https://github.com/franklynw/HalfASheet) + + +## License + +`FontPicker` is available under the MIT license diff --git a/Resources/Example1.png b/Resources/Example1.png new file mode 100644 index 0000000..0f67a9c Binary files /dev/null and b/Resources/Example1.png differ