Skip to main content

Mobile App — UI Design System & Consistency Guidelines

Purpose: This document defines the design rules for typography, spacing, buttons, layout, and component-based structures to enforce visual consistency across the Swopix application. It integrates Android (Material Design 3) and iOS (Apple HIG) developer best practices to eliminate UI fragmentation.


1. Android & Cross-Platform Best Practices

When building cross-platform Flutter applications targeting Android and iOS, developer design patterns should align with standard platform specifications.

1a. Density-Independent Pixels (dp) vs. Scale-Independent Pixels (sp)

  • DP/Logical Pixels: Spacing, sizes, and padding must always be set in logical pixels (dp). Never hardcode physical pixel coordinates.
  • SP (Typography Scaling): Text size must always be set in scale-independent pixels (sp or direct double values in Flutter which automatically scale based on the system's text scale factor).
  • Prohibition of Sizer for Spacing/Text: Do NOT use .w or .h from the sizer package for padding, margins, or text size. Viewport-percentage styling scales uncontrollably, causing stretched components and unreadable text on tablets, foldables, and large screens. Use absolute logical pixels (e.g., 16, 24) for spacing.

1b. Material Design 3 (M3) Specs for Android

  • M3 Grid System: Built on a linear 8dp grid. All spacing, margins, and layout offsets should align with multiples of 8dp (8, 16, 24, 32, 40, 48, 56, 64). A secondary 4dp grid can be used for tight spacing inside dense components (like icon label gaps).
  • Touch Targets: The minimum touch target size for interactive elements on Android (M3 and WCAG 2.1 AA) is 48x48dp. Even if a visual asset is smaller (e.g., a 24dp icon), its clickable container must be padded to at least 48dp.
  • Tonal Elevation: Material Design 3 replaces dark drop shadows with tonal overlays. Surfaces at higher elevations receive a colored overlay derived from the app's primary theme color rather than deep shadows.

2. Typography & Visual Hierarchy

Establishing a strong typographic hierarchy is critical to preventing screens from looking cluttered or flat.

2a. Material Design 3 Typography Scale

Use a unified typography scale to map text elements. Do not introduce arbitrary inline styles.

M3 RoleApp TokenFont SizeWeightLine HeightUsage
Display LargedisplayLarge57spRegular (400)1.1xLarge hero banners
Display SmalldisplaySmall36spRegular (400)1.2xOnboarding titles
Headline SmallheadlineSmall24spSemiBold (600)1.3xScreen headers, modals
Title LargetitleLarge20spSemiBold (600)1.3xApp bar titles, card headers
Title MediumtitleMedium16spMedium (500)1.4xSub-sections, form labels
Title SmalltitleSmall14spMedium (500)1.4xList titles, small section heads
Body LargebodyLarge16spRegular (400)1.5xPrimary reading copy, inputs
Body MediumbodyMedium14spRegular (400)1.5xSecondary descriptions
Body SmallbodySmall12spRegular (400)1.5xSupporting metadata
Label LargelabelLarge14spMedium (500)1.4xButton text, prominent chips
Label SmalllabelSmall12spMedium (500)1.4xBadges, navigation labels

2b. Typographic Rules

  • Minimum Font Size: No text in the app should go below 12sp for readability. Sizes of 7sp, 8sp, or 9sp fail accessibility criteria and are unreadable on high-density displays.
  • Font Weight Hierarchy: Do not mix more than 2-3 weights on a single screen. Prefer Regular (400) for body copy, Medium (500) for labels/buttons, and SemiBold (600) or Bold (700) for headers. Prohibit ExtraBold (800) or Black (900) as they disrupt page hierarchy and look harsh.
  • Letter Spacing: Cap letter-spacing at 0.5px for small labels or badges. Body text must have zero extra letter spacing.

3. Spacing System (8dp Grid)

Spacing should never be arbitrary (e.g. 5, 7, 10, 13, 17, 21).

TokenSizePrimary Usage
space-14dpTight item spacing, icon + label gaps
space-28dpChips/badges, heading to body text
space-312dpHorizontal list items spacing
space-416dpDefault Screen Horizontal Padding
space-520dpInternal card layouts
space-624dpBetween content sections
space-832dpLarge hero element spacing
space-1040dpScreen top/bottom padding offsets
  • Margins: Every screen must respect a 16dp horizontal margin on both sides. No components should touch the edge of the screen.

4. Components & Sizes

4a. Buttons

Buttons should be built as modular widgets. Do not hardcode button widths mid-screen.

  • Width Rules:
    • Full-Width (52dp Height): Belong exclusively at the bottom of the screen for primary CTAs (e.g., "Login", "Confirm", "Post Ad").
    • Wrap-Content (44dp Height): Used inside lists, cards, and mid-screen buttons. They size dynamically with 16dp horizontal padding.
    • Dual Action: Side-by-side buttons of equal width (split screen width minus 8dp spacing).
  • Pressed Feedback: Every button (including custom widgets like GradientButton) must implement pressed states. Use overlays (e.g. black with 10% opacity) or opacity scales (0.8) during click events.

4b. Text Fields

  • Height: Standardized to 56dp (matching M3 Outlined/Filled specs) or 52dp with vertical padding of 14dp and horizontal padding of 16dp.
  • Border Thickness: Default border should be 1dp. Focused and error borders must be 2dp for strong visual contrast.

4c. Cards

  • Border Radius: Standardized to 12dp for all lists and grid cards. Avoid 16dp or 20dp corners to maintain modern, sleek outlines.
  • Inner Padding: Standard card padding is 16dp all sides. Never use tight padding like 8dp or 10dp on main card layouts.

4d. Navigation

  • Top App Bar: Height must be 64dp with centered or left-aligned titles (consistent throughout the app).
  • Bottom Navigation Bar: Height must be 80dp (M3 guideline) with a pill-shaped selection indicator.

5. Component-Based Architecture Best Practices

Developer velocity and UI consistency depend on a strong component structure:

  1. Composition Over Inheritance: Assemble screens using small, single-purpose widgets.
  2. Stateless UI Presentation: Keep layout presentation widgets Stateless where possible. Pass data and callbacks into them.
  3. Themes over Hardcoding: Never hardcode color hex codes (e.g., Color(0xFF9CA3AF)) or style blocks inside text. Instead, refer to Theme.of(context).colorScheme or AppTheme.
  4. Isolate Responsive Widgets: Ensure that dynamic grids and layouts handle content scaling gracefully without breaking (use LayoutBuilder).

6. Swopix Codebase Visual Gaps & Consistency Audit

Below is a detailed list of identified visual design inconsistencies, gaps, and issues in the current Swopix codebase that violate developer best practices.

6a. Typography Hierarchy & Weight Inconsistencies

  • Font Sizes Below Readability Limit:
  • Inconsistent/Extreme Font Weights:
  • Local Overrides vs Centralized Theme:
    • Multiple text styles are hardcoded with local TextStyle blocks containing sizes/colors rather than relying on Theme.of(context).textTheme. For example:

6b. Spacing & Margin Inconsistencies

  • Use of Sizer for Padding & Margins:
  • Arbitrary Margins (Non-multiples of 4):
    • listing_card_widget.dart: Uses padding: const EdgeInsets.fromLTRB(10, 8, 10, 8). 10px horizontal padding violates the 8dp grid spacing standard.

6c. Border Radius Discrepancies

  • Cards Radius Inconsistency:
  • Uneven Image Border Radii:
    • listing_card_widget.dart: Top borders of listing images are clipped using Radius.circular(15) inside a card container of 16px border radius, creating an uneven visual frame.

6d. Touch Target Failures (Below 48x48dp)

  • Toggles & Small Controls:
    • Toggle controls (such as the view togglers in home screens) and icons inside badges (like listing stars or location pins) have small hitboxes that make them difficult to tap on mobile touchscreens.
    • Buttons like _ViewToggleButton at 32x32px and category chips at 40px height do not meet Android's 48dp touch target standards.

7. Refactoring Checklist for Visual Consistency

When clean-up tasks are scheduled, verify:

  • Replace sizer .sp values with standard scale-independent values.
  • Replace .w and .h margins/paddings with static logical dp values.
  • Up-scale all font sizes below 12sp to 12sp (AppTypography.labelSmall).
  • Normalize Card radii from 16px down to 12px.
  • Set minimum heights of default inline buttons to 44dp and ensure they have a tactile pressed state.
  • Ensure all key interactive icons/buttons have an absolute minimum tap box of 48x48dp.