Skip to content

feat(sf-symbols): add disabled prop && lightweight SF Symbols utilities for TypeScript#6

Merged
sbaiahmed1 merged 2 commits intomainfrom
feat/add-sf-symbols-support-ios
Oct 30, 2025
Merged

feat(sf-symbols): add disabled prop && lightweight SF Symbols utilities for TypeScript#6
sbaiahmed1 merged 2 commits intomainfrom
feat/add-sf-symbols-support-ios

Conversation

@sbaiahmed1
Copy link
Copy Markdown
Owner

@sbaiahmed1 sbaiahmed1 commented Oct 29, 2025

Introduce branded string type, version support mapping, validators and common examples for IDE hinting. Avoids bundling full symbol list while providing type safety.

Add support for disabling menu interactions through a new disabled prop. When disabled, the menu won't respond to touch events and will visually indicate its disabled state. This includes platform-specific implementations for both iOS and Android, along with documentation and example usage.

Summary by Sourcery

Add lightweight SF Symbols utilities in TypeScript and integrate optional iosSymbol support in MenuView, updating native code and example app to showcase icon rendering and UI refinements.

New Features:

  • Provide SFSymbol branded string type, version support mapping, heuristic validator, and a set of common symbols for IDE hinting
  • Add optional iosSymbol prop to MenuItem to enable SF Symbol icons alongside menu item titles

Enhancements:

  • Extend iOS MenuView native component to detect iosSymbol changes and render SF Symbol system images
  • Re-export SF Symbols utilities (asSFSymbol, isLikelySFSymbol, CommonSFSymbols) from the module index
  • Update example app to import and use asSFSymbol for menu icons, remove console logs, rename labels, and refine UI styling

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Oct 29, 2025

Reviewer's Guide

Introduces a lightweight SF Symbols helpers module in TypeScript with branded types, version support and validators; extends the native iOS MenuView component to accept and render an optional iosSymbol prop as UIImage; and updates the example App to showcase using asSFSymbol in menu items along with adjusted labels and styles.

Sequence diagram for rendering menu items with SF Symbols in iOS MenuView

sequenceDiagram
    participant JS as "JS (React Native)"
    participant Native as "NativeMenuView"
    participant iOS as "iOS MenuView"
    participant UIKit as "UIKit"
    JS->>Native: Pass menuItems with iosSymbol
    Native->>iOS: Update props with menuItems
    iOS->>UIKit: Create UIImage from iosSymbol
    UIKit-->>iOS: Return UIImage
    iOS->>Native: Render menu with icon
    Native-->>JS: Display menu with SF Symbol icon
Loading

Class diagram for new SF Symbols utilities and MenuItem changes

classDiagram
    class SFSymbol {
      <<type>>
      +string (branded)
    }
    class SFSymbolVersion {
      <<type>>
      +"1.0" | "1.1" | "2.0" | "2.1" | "2.2" | "3.0" | "3.1" | "3.2" | "3.3" | "4.0" | "4.1" | "4.2" | "5.0" | "5.1" | "5.2" | "5.3" | "6.0"
    }
    class SFSymbolsVersionSupport {
      +ios: string
      +macos: string
      +tvos: string
      +visionos: string
      +watchos: string
    }
    class MenuItem {
      +identifier: string
      +title: string
      +iosSymbol: string
    }
    class sf_symbols_ts {
      +isLikelySFSymbol(name: string): boolean
      +asSFSymbol(name: string): SFSymbol
      +CommonSFSymbols: string[]
    }
    SFSymbolsVersionSupport <|-- SFSymbolVersion
    sf_symbols_ts ..> SFSymbol
    sf_symbols_ts ..> SFSymbolVersion
    MenuItem o-- SFSymbol
Loading

File-Level Changes

Change Details Files
Add lightweight SF Symbols utilities in TypeScript
  • Declared branded SFSymbol type and SFSymbolVersion mapping
  • Provided SFSymbolsVersionSupport constant and CommonSFSymbols for IDE hints
  • Implemented isLikelySFSymbol validator and asSFSymbol cast function with dev-time warning
  • Re-exported SF Symbols APIs and extended MenuItem interface with iosSymbol
src/sf-symbols.ts
src/index.tsx
src/MenuViewNativeComponent.ts
Extend native iOS MenuView to support iosSymbol prop
  • Detect iosSymbol differences in updateProps to trigger rebuilds
  • Include iosSymbol in menuItems dictionaries
  • Instantiate UIImage via systemImageNamed when rendering actions
ios/MenuView.mm
Update example App to demonstrate SF Symbol integration
  • Import asSFSymbol and assign iosSymbol to menuItems
  • Removed debug console.logs and adjusted menu labels and button icons
  • Refined stylesheet values for spacing, typography and colors
example/src/App.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `src/sf-symbols.ts:156-164` </location>
<code_context>
+ * Accepts dot-separated lowercase tokens with numbers (e.g. "arrow.up.circle.fill").
+ * This is not exhaustive, but helps catch obvious mistakes without enumerating names.
+ */
+export function isLikelySFSymbol(name: string): boolean {
+  if (name.length < 2 || name.length > 128) return false;
+  return /^[a-z0-9]+(?:\.[a-z0-9]+)*$/.test(name);
</code_context>

<issue_to_address>
**suggestion:** The SF Symbol validator may reject valid symbol names with uppercase or underscores.

The current regex excludes valid SF Symbol names containing uppercase letters or underscores. Please update the regex to accommodate these cases or clarify this limitation in the documentation.

```suggestion
/**
 * Heuristic validator for SF Symbol names.
 * Accepts dot-separated tokens with letters (uppercase and lowercase), numbers, and underscores (e.g. "arrow.up.circle.fill", "Arrow_Up.Circle.Fill").
 * This is not exhaustive, but helps catch obvious mistakes without enumerating names.
 */
export function isLikelySFSymbol(name: string): boolean {
  if (name.length < 2 || name.length > 128) return false;
  return /^[A-Za-z0-9_]+(?:\.[A-Za-z0-9_]+)*$/.test(name);
}
```
</issue_to_address>

### Comment 2
<location> `src/sf-symbols.ts:170-178` </location>
<code_context>
  if (__DEV__) {
    if (!isLikelySFSymbol(name)) {
      // non-throwing hint; consumers can choose to throw if they prefer

      console.warn(
        `[menu] Provided iosSymbol "${name}" does not match common SF Symbol naming patterns.`
      );
    }
  }

</code_context>

<issue_to_address>
**suggestion (code-quality):** Merge nested if conditions ([`merge-nested-ifs`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/TypeScript/Default-Rules/merge-nested-ifs))

```suggestion
  if (__DEV__ && !isLikelySFSymbol(name)) {
        console.warn(
          `[menu] Provided iosSymbol "${name}" does not match common SF Symbol naming patterns.`
        );
  }

```

<br/><details><summary>Explanation</summary>Reading deeply nested conditional code is confusing, since you have to keep track of which
conditions relate to which levels. We therefore strive to reduce nesting where
possible, and the situation where two `if` conditions can be combined using
`and` is an easy win.
</details>
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/sf-symbols.ts
Comment thread src/sf-symbols.ts
@sbaiahmed1 sbaiahmed1 changed the title feat(sf-symbols): add lightweight SF Symbols utilities for TypeScript feat(sf-symbols): add disabled prop && lightweight SF Symbols utilities for TypeScript Oct 29, 2025
@sbaiahmed1 sbaiahmed1 force-pushed the feat/add-sf-symbols-support-ios branch from 562372c to e81c971 Compare October 30, 2025 22:37
@sbaiahmed1 sbaiahmed1 merged commit 9bb9c52 into main Oct 30, 2025
6 checks passed
@sbaiahmed1 sbaiahmed1 deleted the feat/add-sf-symbols-support-ios branch October 30, 2025 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant