React Native Assignment– 4
Styling & Theming
Basic Questions
- Create a screen that uses StyleSheet.create to style a centered “Hello Styling” text (font size 24, bold, primary color).
- Build a header–content–footer layout with Flexbox (flexDirection, justifyContent, alignItems) and distinct background colors.
- Convert inline styles in a component to a shared styles.js module and import them.
- Add a responsive container that pads horizontally by 16 on phones and 24 on tablets using Dimensions.
- Create a two-column grid of cards using Flexbox wrapping; maintain equal spacing.
- Style a <TextInput> with rounded corners and shadow/elevation; ensure shadow shows on iOS and elevation on Android.
- Add a StatusBar with dark content on light background and verify contrast.
- Use Platform.select to apply platform-specific fonts (e.g., System vs Roboto).
- Implement a pressable button that visually shows pressed state (opacity or scale) via Pressable style callback.
- Create a SafeAreaView wrapper and verify no content overlaps with notches.
- Use PixelRatio.getFontScale() to adjust a title’s font size for large accessibility settings.
- Add an image banner that maintains aspect ratio using resizeMode=”cover” inside a fixed-height container.
- Build a “tag” pill component with rounded background and uppercase text; reuse it in a list.
- Implement a divider component that draws a 1px hairline using StyleSheet.hairlineWidth.
- Create a reusable Spacer component with a size prop and use it between stacked items.
- Apply numberOfLines and ellipsizeMode=”tail” to truncate a long title elegantly.
- Add RTL support: set flexDirection based on I18nManager.isRTL and verify layout flips.
- Create a color constants file (theme/colors.ts|js) and replace hard-coded colors across one screen.
- Build a card with shadow on iOS and elevation on Android; verify parity visually.
- Add a KeyboardAvoidingView that shifts a form up, and keep the submit button pinned to bottom with Flexbox.
Intermediate Questions
- Create a responsive grid that shows 2 columns on narrow screens and 3 on wide screens using Dimensions and calculated item width.
- Implement scalable typography: write a scaleFont(size) helper using Dimensions/PixelRatio and apply to headings/body.
- Add dark mode support using the Appearance API; swap light/dark color palettes automatically.
- Provide a manual theme toggle button that overrides system theme via React Context (ThemeContext).
- Animate theme changes (background and text colors) using Animated.Value or react-native-reanimated.
- Build a reusable Button component that supports variant=”primary|secondary|ghost” with consistent padding, radius, and typography.
- Implement a skeleton loader (animated shimmer) placeholder for list items while content loads.
- Create a sticky header list using SectionList with styled section headers and subtle separators.
- Implement an image grid with lazy-loading thumbnails and a blurred placeholder until loaded.
- Extract spacing and radius into a theme/spacing & theme/radius scale; refactor one screen to use tokens only.
- Introduce semantic color tokens (e.g., background, surface, textPrimary, textSecondary, accent) and map to light/dark palettes.
- Build a settings page that previews theme changes live across sample components (buttons, text, cards).
- Add platform-consistent shadows: create a helper shadow(elevation) that returns iOS shadow props and Android elevation.
- Implement a Container component that constrains content to a max width and centers it on tablets.
- Use Pressable style callback to implement hover (web), focus (TV), and pressed states with different styles where supported.
- Create a “chip group” with selectable chips; selected chips change background and text color using theme tokens.
- Add a Modal with dimmed backdrop; ensure backdrop blocks touches and supports light/dark opacity.
- Implement a responsive hero banner: text on top of image for phones, side-by-side for tablets (orientation-aware).
- Build a ListItem with left icon, title, subtitle, and right accessory; ensure correct vertical rhythms (line heights).
- Generate a simple design audit: list every color and font size used on two screens and consolidate them into tokens.
Advanced Questions
- Create a full theming system using React Context or a library (e.g., react-native-paper/styled-components): light, dark, and high-contrast themes, with persistence (AsyncStorage).
- Implement dynamic color adaptation using iOS Material/semantic colors or Android dynamic color (where available) with graceful fallbacks.
- Build a virtualized masonry grid (variable card heights) with performant item renderers and recycled cells.
- Add code-splitting/lazy loading for heavy UI subtrees (e.g., charts) and show a themed fallback skeleton until loaded.
- Implement a perf-safe long list item: memoize row components, stabilize keyExtractor, and avoid inline closures to minimize re-renders.
- Create a theme-driven design system: Text, Heading, Button, Card, Surface, Input, each consuming tokens and supporting states (disabled, loading, error).
- Build an accessibility review overlay: toggle an overlay that highlights low-contrast text and missing hit-slope areas (<44×44) and logs issues to console.
- Add adaptive layouts for foldables/tablets: detect window segments and reposition panes accordingly.
- Implement runtime font loading (custom fonts) with fallback stacks; ensure text reflow doesn’t cause layout shift by precomputing metrics where possible.
- Final Hands-on Project:
- Set up a token-based theme (colors, spacing, radius, typography) with light/dark + high-contrast variants
- Provide system/dynamic theme detection with manual override and persistence
- Build 3 sample screens (Dashboard, List, Details) using only design-system components
- Add skeleton loaders, lazy-loaded heavy components, and responsive layouts for phone/tablet
- Ensure accessibility (contrast, hit targets, semantics) and RTL layout parity
- Profile re-renders and fix hotspots; document measurable improvements (FPS, memory, re-render counts)