diff --git a/plan/README.md b/plan/README.md new file mode 100644 index 000000000..2a468aabe --- /dev/null +++ b/plan/README.md @@ -0,0 +1,237 @@ +# Plan module + +Contains sub-modules: +- dagger: Dagger Injection/Module(s). +- data: Data layer. +- domain: Domain layer. +- presentation: Presentation layer. + +### Quickstart + +Product have to provide a configuration: + +``` +@Module +@InstallIn(SingletonComponent::class) +object PlansModule { + + @Provides + @SupportSignupPaidPlans + fun provideSupportSignupPaidPlans() = true + + @Provides + @SupportUpgradePaidPlans + fun provideSupportUpgradePaidPlans() = true + + @Provides + @ProductOnlyPaidPlans + fun provideProductOnlyPaidPlans() = false + + @Provides + fun provideClientPlansFilterPredicate(): ClientPlanFilter? = null +} +``` +- SupportSignupPaidPlans: true to show Paid plan(s) during SignUp. +- SupportUpgradePaidPlans: true to show Paid plan(s) during Upgrade. +- ProductOnlyPaidPlans: true if Product support only Paid plan(s). +- ClientPlanFilter: Any client additional plan filter (e.g. during SignUp or Upgrade). + +### Plan Layouts & Mapping + +By default the presentation module will use predefined layouts to show plans. + +There are 2 different layout categories: +- **Current** plan layout: displayed on subscription screen. +- **Paid** plan layout: displayed on SignUp/Upgrade screen, for plan selection. + +Here is the list of existing plans (with corresponding default layout): +- free: `plan_id_free`. +- plus: `plan_id_plus`. +- vpnbasic: `plan_id_vpnbasic`. +- vpnplus: `plan_id_vpnplus`. +- professional: `plan_id_professional`. +- visionary: `plan_id_visionary`. +- mail2022: `plan_id_mail2022`. +- vpn2022: `plan_id_vpn2022`. +- drive2022: `plan_id_drive2022`. +- bundle2022: `plan_id_bundle2022`. +- pass2023: `plan_id_pass2023`. + +Corresponding layouts are defined in `values/plans_layouts.xml`. + +Defining a layout consist of declaring 3 arrays : +- The order array (`${prefix}_order`) is defining item type: + - `string`: Any string. + - `#proton_users#`: Predefined users feature (e.g. "10 users" or "1 of 10 users"). + - `#proton_storage#`: Predefined storage feature (e.g. "500GB storage"). + - `#proton_addresses#`: Predefined addresses feature (e.g. "15 email addresses" or "1 of 15 addresses"). + - `#proton_calendars#`: Predefined calendars feature (e.g. "25 personal calendars" or "1 of 25 calendars"). + - `#proton_vpn#`: Predefined vpn feature (e.g. "Free VPN on single device" or "High-speed VPN on 10 devices"). + - `#proton_domains#`: Predefined domains feature (e.g. "Support for 1 custom email domain"). + - Note: Predefined features are dynamic according plan capabilities and support singular and plurals (e.g. "1 of 1 address" vs "1 of 10 addresses"). +- The icons array (`${prefix}_icons`) is defining item icons (e.g. "@drawable/ic_proton_storage"). +- The text array ((`${prefix}`)): Define text of item (e.g. "@string/plan_id_free_header"): + - The first item is the text header, the plan description during plan selection. + - The next items are the corresponding texts for other items. + +For example, `plan_id_free`: +``` + + #proton_storage# + #proton_addresses# + #proton_calendars# + #proton_vpn# + + + @drawable/ic_proton_storage + @drawable/ic_proton_envelope + @drawable/ic_proton_calendar_checkmark + @drawable/ic_proton_shield + + + @string/plan_id_free_header + @plurals/item_storage_free + @plurals/item_address + @plurals/item_calendar + @plurals/item_connections + +``` + +Layouts to be used are defined in `values/plans_mapping.xml`. +- Client can **override** or add any plan layouts if needed, in **their own codebase**. +- Client can **override** any plan mapping if needed, in **their own codebase**. +- Client **cannot** add a new plan id. It must be added in Core first. + +By default: +- All plans are using the same current plan layout. +- All plans have their corresponding paid plan layout. +``` + + + free + plus + vpnbasic + vpnplus + professional + visionary + mail2022 + vpn2022 + drive2022 + bundle2022 + pass2023 + + + plan_current + plan_current + plan_current + plan_current + plan_current + plan_current + plan_current + plan_current + plan_current + plan_current + plan_current + + + plan_id_free + plan_id_plus + plan_id_vpnbasic + plan_id_vpnplus + plan_id_professional + plan_id_visionary + plan_id_mail2022 + plan_id_vpn2022 + plan_id_drive2022 + plan_id_bundle2022 + plan_id_pass2023 + + +``` + +Here is an example where a client override **current** plans mapping. + +Add new layouts in a new `plans_layouts.xml` file, in client side: +``` + + + string + string + string + string + + + @drawable/ic_proton_infinite + @drawable/ic_proton_infinite + @drawable/ic_proton_alias + @drawable/ic_proton_vault + + + @string/plan_id_pass2023_header + @string/unlimited_logins_and_notes + @string/unlimited_devices + @string/ten_hide_my_email_aliases + @string/one_vault + + + + string + string + string + #proton_storage# + #proton_addresses# + #proton_vpn# + + + @drawable/ic_proton_lock + @drawable/ic_proton_vault + @drawable/ic_proton_alias + @drawable/ic_proton_storage + @drawable/ic_proton_at + @drawable/ic_proton_shield + +