New SwiftUI Modifiers Implementation ​
This document explains the implementation of two new SwiftUI modifiers in TachUI:
1. .resizable() Modifier ​
Purpose ​
The .resizable() modifier makes images resizable, allowing them to scale to fit their container. In SwiftUI, this is commonly used with Image views to make them scale appropriately.
Implementation Details ​
- Class:
ResizableModifierinbase.ts - Type: Appearance modifier
- Priority: APPEARANCE (200)
- Functionality: Sets
object-fit: fillon image elements
Usage ​
typescript
Image("my-photo.jpg")
.modifier
.resizable()
.frame(200, 150)
.build()CSS Equivalent ​
css
img {
object-fit: fill;
}2. .textCase() Alias ​
Purpose ​
.textCase() is an alias for the existing .textTransform() modifier, providing API parity with SwiftUI's .textCase() modifier.
Implementation Details ​
- Function:
textCase()intypography.ts - Type: Typography modifier
- Functionality: Calls
textTransform()with the same parameters
Usage ​
typescript
Text("Hello World")
.modifier
.textCase('uppercase') // Same as .textTransform('uppercase')
.build()Supported Values ​
'none'- No transformation'uppercase'- All uppercase'lowercase'- All lowercase'capitalize'- First letter of each word capitalized
CSS Equivalent ​
css
.text {
text-transform: uppercase; /* or lowercase, capitalize, none */
}Implementation Files ​
base.ts- AddedResizableModifierclassbuilder.ts- Added.resizable()method toModifierBuilderImpltypography.ts- AddedtextCase()alias functionindex.ts- Exported new modifier and aliastypes.ts- Added method signatures toModifierBuilderinterface__tests__/new-modifiers.test.ts- Test suite for new modifiersapps/examples/new-modifiers-demo.ts- Usage examples
Testing ​
The new modifiers have been tested with:
- Basic functionality tests
- Integration with existing modifier system
- Edge cases (non-image elements for resizable)
All tests pass, confirming that the new modifiers work correctly with the existing TachUI modifier system.