Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Javascript API to customize the font picker #363

Merged
merged 3 commits into from
May 25, 2020

Conversation

radazzouz
Copy link
Contributor

@radazzouz radazzouz commented Apr 13, 2020

Solves #320


Details

Adds Javascript API to customize the font picker.

The exposed React Native props:

  /**
   * availableFontNames: Can be used to specfiy the available font names in the font picker.
   * Note: You need to set the desired font family names as `UIFontDescriptor`. See https://developer.apple.com/documentation/uikit/uifontdescriptor?language=objc
   * See `CustomFontPicker` in https://github.com/PSPDFKit/react-native/blob/master/samples/Catalog/Catalog.ios.js
   *
   * @platform ios
   */
  availableFontNames: PropTypes.array,
  /**
   * selectedFontName: Can be used to specfiy the current selected font in the font picker.
   * Note: You need to set the desired font family name as `UIFontDescriptor`. See https://developer.apple.com/documentation/uikit/uifontdescriptor?language=objc
   * See `CustomFontPicker` in https://github.com/PSPDFKit/react-native/blob/master/samples/Catalog/Catalog.ios.js
   *
   * @platform ios
   */
  selectedFontName: PropTypes.string,
  /**
   * showDownloadableFonts: Can be used to show or hide the downloadable fonts section in the font picker. Defaults to showing a the downloadable fonts (true).
   * See `CustomFontPicker` in https://github.com/PSPDFKit/react-native/blob/master/samples/Catalog/Catalog.ios.js
   *
   * @platform ios
   */
  showDownloadableFonts: PropTypes.bool,

recording

Acceptance Criteria

  • Add Javascript API to customize the font picker on Android.
  • Add Javascript API to customize the font picker on iOS.
  • When approved, right before merging, rebase with master and increment the package version in package.json, package-lock.json, samples/Catalog/package.json, and samples/NativeCatalog/package.json (see example commit: 1bf805f).
  • Create a new release (and tag) with the new package version (see https://github.com/PSPDFKit/react-native/releases).

@radazzouz radazzouz force-pushed the customize-font-picker branch from 799b33e to 39a5970 Compare April 15, 2020 13:50
index.js Show resolved Hide resolved
@radazzouz radazzouz requested a review from irgendeinich May 6, 2020 11:35
@radazzouz radazzouz requested a review from steviki May 6, 2020 11:38
Copy link
Contributor

@steviki steviki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Just a question about the custom subclass override.

// We use a subclassed font picker view controller to customize it.
[view.pdfController updateConfigurationWithoutReloadingWithBuilder:^(PSPDFConfigurationBuilder * _Nonnull builder) {
[builder overrideClass:PSPDFFontPickerViewController.class withClass:CustomFontPickerViewController.class];
}];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we always use the custom override, so we don't need to update the configuration all the time one of these properties is set, and just fallback to the default behavior, when none of these variables are set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! 👍 Addressed in cc92d1a

@irgendeinich irgendeinich requested a review from simoarpe May 11, 2020 07:48
@radazzouz radazzouz changed the title Adds Javascript API to customize the font picker. Adds Javascript API to customize the font picker May 18, 2020
Copy link
Contributor

@simoarpe simoarpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Android part looks good 👍

@radazzouz radazzouz merged commit b0bd2aa into master May 25, 2020
@radazzouz radazzouz deleted the customize-font-picker branch May 25, 2020 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants