Skip to content

Commit 63c71f2

Browse files
authored
Merge pull request #2 from mCodex/feat/exampleRefactor
Feat/example refactor
2 parents adfbf43 + 8ec8fd7 commit 63c71f2

31 files changed

+2939
-963
lines changed

README.md

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,148 @@ enum InstallmentType {
179179
}
180180
```
181181

182+
## 🎨 UI Customization & Theming
183+
184+
Customize the appearance of PagBank SDK modal dialogs to match your app's design. The library provides complete control over colors, themes, and UI elements displayed during payment transactions.
185+
186+
<div align="center">
187+
<img src="https://github.com/mCodex/react-native-plugpag-nitro/assets/modal-example.png" alt="Customizable Payment Modal" width="400"/>
188+
<p><em>Payment modal with custom dark theme matching your app's design</em></p>
189+
</div>
190+
191+
### ⚡ Quick Theme Setup
192+
193+
```typescript
194+
import { setStyleTheme } from 'react-native-plugpag-nitro';
195+
196+
// Create and apply a custom theme
197+
await setStyleTheme({
198+
headBackgroundColor: '#1A1A1D', // Header background
199+
headTextColor: '#FFFFFF', // Header text
200+
positiveButtonBackground: '#22C55E', // "Confirm" button color
201+
negativeButtonBackground: '#EF4444', // "Cancel" button color
202+
contentTextColor: '#FFFFFF', // Body text color
203+
lineColor: '#71717A' // Borders and lines
204+
});
205+
```
206+
207+
### 🛠️ Custom Theme Creation
208+
209+
Create themes that match your app's design system:
210+
211+
```typescript
212+
// Create a custom brand-based theme
213+
const customTheme = {
214+
headBackgroundColor: '#00D4FF', // Your primary brand color
215+
headTextColor: '#FFFFFF', // White text on colored header
216+
contentTextColor: '#1A1A1D', // Dark text for body content
217+
positiveButtonBackground: '#00D4FF', // Consistent brand color
218+
negativeButtonBackground: '#EF4444', // Standard red for cancel
219+
lineColor: '#E5E7EB' // Light gray for borders
220+
};
221+
222+
await setStyleTheme(customTheme);
223+
```
224+
225+
### 🎨 Complete Style Properties
226+
227+
<details>
228+
<summary><strong>📋 All available style properties</strong></summary>
229+
230+
```typescript
231+
interface PlugpagStyleData {
232+
// Header styling
233+
headTextColor?: string; // Header text color
234+
headBackgroundColor?: string; // Header background color
235+
236+
// Content styling
237+
contentTextColor?: string; // General content text
238+
contentTextValue1Color?: string; // Primary monetary values
239+
contentTextValue2Color?: string; // Secondary monetary values
240+
241+
// Button styling
242+
positiveButtonTextColor?: string; // Confirm button text
243+
positiveButtonBackground?: string; // Confirm button background
244+
negativeButtonTextColor?: string; // Cancel button text
245+
negativeButtonBackground?: string; // Cancel button background
246+
genericButtonBackground?: string; // Generic button background
247+
genericButtonTextColor?: string; // Generic button text
248+
249+
// Input field styling
250+
genericSmsEditTextBackground?: string; // SMS input background
251+
genericSmsEditTextTextColor?: string; // SMS input text
252+
253+
// Interface elements
254+
lineColor?: string; // Lines, borders, dividers
255+
}
256+
```
257+
258+
</details>
259+
260+
### 🔧 Theme Utilities
261+
262+
```typescript
263+
import { ThemeUtils } from 'react-native-plugpag-nitro';
264+
265+
// Validate theme colors
266+
const errors = ThemeUtils.validateTheme(myTheme);
267+
if (errors.length === 0) {
268+
await setStyleTheme(myTheme);
269+
}
270+
271+
// Merge themes
272+
const customizedTheme = ThemeUtils.mergeThemes(
273+
baseTheme, // Your base theme
274+
{ positiveButtonBackground: '#FF6B6B' }
275+
);
276+
277+
// Preview theme colors (for debugging)
278+
const preview = ThemeUtils.createThemePreview(myTheme);
279+
console.log(preview); // { headBackgroundColor: '#1A1A1D', ... }
280+
```
281+
282+
### 💡 Best Practices
283+
284+
- **Apply early**: Set themes during app initialization, before payment operations
285+
- **Match your design**: Use colors that complement your existing UI
286+
- **Accessibility**: Ensure sufficient contrast between text and backgrounds
287+
- **Validation**: Always validate themes before applying them
288+
- **Error handling**: Wrap theme operations in try-catch blocks
289+
290+
### 🏗️ Integration Example
291+
292+
```typescript
293+
import React, { useEffect } from 'react';
294+
import { setStyleTheme } from 'react-native-plugpag-nitro';
295+
296+
export default function App() {
297+
useEffect(() => {
298+
// Apply theme matching your app's design
299+
const initializeTheme = async () => {
300+
try {
301+
const customTheme = {
302+
headBackgroundColor: '#1A1A1D',
303+
headTextColor: '#FFFFFF',
304+
positiveButtonBackground: '#22C55E',
305+
negativeButtonBackground: '#EF4444'
306+
};
307+
308+
await setStyleTheme(customTheme);
309+
console.log('Theme applied successfully');
310+
} catch (error) {
311+
console.error('Failed to apply theme:', error);
312+
}
313+
};
314+
315+
initializeTheme();
316+
}, []);
317+
318+
// ... rest of your app
319+
}
320+
```
321+
322+
> 📖 **Complete styling guide**: See [STYLING_GUIDE.md](STYLING_GUIDE.md) for detailed documentation and examples.
323+
182324
## 💡 Usage Examples
183325

184326
### Complete Payment Flow

0 commit comments

Comments
 (0)