Flutter UI Walkthrough — Policy Viewer
What the shopper sees
A pill-style tab bar with three tabs — Terms & Conditions, Privacy Policy, Returns & Exchange — and the selected document’s full text rendered below it. A loading state shows while content is fetched, with a retry option if the fetch fails.
What the shopper does here
- Switches between the three tabs to read any of the three documents.
- Reads the content; there is no acceptance action on this screen itself — consent is captured back on the signup screen’s checkbox.
How it’s built
PolicyViewerController exposes selectedTab (.obs, defaulting to PolicyViewerController.tabTerms), policy (a getter forwarding PolicyService.currentPolicy, an Rxn<PolicyModel>), and isLoading (forwarding PolicyService.isLoading). onInit() reads Get.arguments['initialTab'] if present — this lets phone_signup_view.dart’s “Read Terms & Policies” link open directly to a specific tab rather than always defaulting to Terms — then calls PolicyService.loadPolicies(). selectTab(tab) just reassigns selectedTab.value; switching tabs doesn’t re-fetch, since all three documents arrive in one PolicyModel response.
PolicyService.loadPolicies() is fetch-once and cache-if-successful: a repeat call while currentPolicy.value is already populated is a no-op, mirroring ThemeService’s shape. The underlying PolicyRepository.getPolicies() calls GET /client/api/v1/policies — reachable pre-login through Nginx’s /app/policies alias — and returns null on any failure rather than falling back to bundled static text; a failed fetch shows a retry affordance instead of stale or placeholder content. This is also why PhoneSignupController falls back to hardcoded 'v1'/'v1' version constants if the same fetch fails there: the signup screen has no document text to show either way, but it still needs some version value to stamp onto the consent action.
The view itself uses PreAuthLayout, AnimatedPillTabBar for the tab control, and the shared PolicyDocumentView widget to render whichever document is selected — the same PolicyDocumentView is reused post-login by the Settings feature’s standalone terms_view.dart/privacy_view.dart screens, so a layout change to document rendering only needs to happen in one place.



Related Documents
- user-secure-engine
- Architecture — Mobile Login & Signup: Component Topology and Data Flow
- ADR-00041
- Reference: Tenant Master — Step 5: Terms & Conditions — where the tenant admin authors and versions this document
- Reference: Tenant Master — Step 6: Privacy Policy — where the tenant admin authors and versions this document
- Reference: Tenant Master — Step 7: Exchange & Returns — where the tenant admin authors and versions this document
- Previous: Phone Signup