fix(mobile): URL changement mdp corrigée + v3.0 — multi-org, AppAuth, sécurité prod
Auth: - profile_repository.dart: /api/auth/change-password → /api/membres/auth/change-password Multi-org (Phase 3): - OrgSelectorPage, OrgSwitcherBloc, OrgSwitcherEntry - org_context_service.dart: headers X-Active-Organisation-Id + X-Active-Role Navigation: - MorePage: navigation conditionnelle par typeOrganisation - Suppression adaptive_navigation (remplacé par main_navigation_layout) Auth AppAuth: - keycloak_webview_auth_service: fixes AppAuth Android - AuthBloc: gestion REAUTH_REQUIS + premierLoginComplet Onboarding: - Nouveaux états: payment_method_page, onboarding_shared_widgets - SouscriptionStatusModel mis à jour StatutValidationSouscription Android: - build.gradle: ProGuard/R8, network_security_config - Gradle wrapper mis à jour
This commit is contained in:
@@ -3,8 +3,11 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../bloc/onboarding_bloc.dart';
|
||||
import '../../data/models/formule_model.dart';
|
||||
import '../../../../features/authentication/presentation/bloc/auth_bloc.dart';
|
||||
import '../../../../shared/design_system/tokens/unionflow_colors.dart';
|
||||
import 'onboarding_shared_widgets.dart';
|
||||
|
||||
/// Étape 2 — Choix de la période de facturation et du type d'organisation
|
||||
/// Étape 2 — Choix de la période de facturation
|
||||
/// Le type d'organisation est récupéré automatiquement depuis le backend.
|
||||
class PeriodSelectionPage extends StatefulWidget {
|
||||
final String codeFormule;
|
||||
final String plage;
|
||||
@@ -23,35 +26,23 @@ class PeriodSelectionPage extends StatefulWidget {
|
||||
|
||||
class _PeriodSelectionPageState extends State<PeriodSelectionPage> {
|
||||
String _selectedPeriode = 'MENSUEL';
|
||||
String _selectedTypeOrg = 'ASSOCIATION';
|
||||
|
||||
static const _periodes = [
|
||||
('MENSUEL', 'Mensuel', 'Aucune remise', 1.00),
|
||||
('TRIMESTRIEL', 'Trimestriel', '5% de remise', 0.95),
|
||||
('SEMESTRIEL', 'Semestriel', '10% de remise', 0.90),
|
||||
('ANNUEL', 'Annuel', '20% de remise', 0.80),
|
||||
];
|
||||
|
||||
static const _typesOrg = [
|
||||
('ASSOCIATION', 'Association / ONG locale', '×1.0'),
|
||||
('MUTUELLE', 'Mutuelle (santé, fonctionnaires…)', '×1.2'),
|
||||
('COOPERATIVE', 'Coopérative / Microfinance', '×1.3'),
|
||||
('FEDERATION', 'Fédération / Grande ONG', '×1.0 ou ×1.5 Premium'),
|
||||
_Periode('MENSUEL', 'Mensuel', '1 mois', null, 1, 1.00),
|
||||
_Periode('TRIMESTRIEL', 'Trimestriel', '3 mois', '–5%', 3, 0.95),
|
||||
_Periode('SEMESTRIEL', 'Semestriel', '6 mois', '–10%', 6, 0.90),
|
||||
_Periode('ANNUEL', 'Annuel', '12 mois', '–20%', 12, 0.80),
|
||||
];
|
||||
|
||||
FormuleModel? get _formule => widget.formules
|
||||
.where((f) => f.code == widget.codeFormule && f.plage == widget.plage)
|
||||
.firstOrNull;
|
||||
|
||||
double get _prixEstime {
|
||||
double _estimerPrix(String periodeCode) {
|
||||
final f = _formule;
|
||||
if (f == null) return 0;
|
||||
final coefPeriode =
|
||||
_periodes.firstWhere((p) => p.$1 == _selectedPeriode).$4;
|
||||
final coefOrg =
|
||||
_selectedTypeOrg == 'COOPERATIVE' ? 1.3 : _selectedTypeOrg == 'MUTUELLE' ? 1.2 : 1.0;
|
||||
final nbMois = {'MENSUEL': 1, 'TRIMESTRIEL': 3, 'SEMESTRIEL': 6, 'ANNUEL': 12}[_selectedPeriode]!;
|
||||
return f.prixMensuel * coefOrg * coefPeriode * nbMois;
|
||||
final p = _periodes.firstWhere((x) => x.code == periodeCode);
|
||||
return f.prixMensuel * p.coef * p.nbMois;
|
||||
}
|
||||
|
||||
String get _organisationId {
|
||||
@@ -69,156 +60,363 @@ class _PeriodSelectionPageState extends State<PeriodSelectionPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final prixSelected = _estimerPrix(_selectedPeriode);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Période & type d\'organisation'),
|
||||
leading: BackButton(
|
||||
onPressed: () => context.read<OnboardingBloc>().add(
|
||||
OnboardingStarted(initialState: 'NO_SUBSCRIPTION'),
|
||||
),
|
||||
),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_StepIndicator(current: 2, total: 3),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Période
|
||||
Text('Période de facturation', style: theme.textTheme.titleMedium),
|
||||
const SizedBox(height: 8),
|
||||
..._periodes.map((p) {
|
||||
final (code, label, remise, _) = p;
|
||||
final selected = _selectedPeriode == code;
|
||||
return RadioListTile<String>(
|
||||
value: code,
|
||||
groupValue: _selectedPeriode,
|
||||
onChanged: (v) => setState(() => _selectedPeriode = v!),
|
||||
title: Text(label,
|
||||
style: TextStyle(
|
||||
fontWeight:
|
||||
selected ? FontWeight.bold : FontWeight.normal)),
|
||||
subtitle: Text(remise,
|
||||
style: TextStyle(
|
||||
color: code != 'MENSUEL' ? Colors.green[700] : null)),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
side: BorderSide(
|
||||
color: selected
|
||||
? theme.primaryColor
|
||||
: Colors.grey[300]!,
|
||||
),
|
||||
),
|
||||
tileColor:
|
||||
selected ? theme.primaryColor.withOpacity(0.05) : null,
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
);
|
||||
}),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
Text('Type de votre organisation', style: theme.textTheme.titleMedium),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'Détermine le coefficient tarifaire applicable.',
|
||||
style:
|
||||
theme.textTheme.bodySmall?.copyWith(color: Colors.grey[600]),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
..._typesOrg.map((t) {
|
||||
final (code, label, coef) = t;
|
||||
final selected = _selectedTypeOrg == code;
|
||||
return RadioListTile<String>(
|
||||
value: code,
|
||||
groupValue: _selectedTypeOrg,
|
||||
onChanged: (v) => setState(() => _selectedTypeOrg = v!),
|
||||
title: Text(label),
|
||||
subtitle: Text('Coefficient : $coef',
|
||||
style: const TextStyle(fontSize: 12)),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
side: BorderSide(
|
||||
color: selected ? theme.primaryColor : Colors.grey[300]!,
|
||||
),
|
||||
),
|
||||
tileColor:
|
||||
selected ? theme.primaryColor.withOpacity(0.05) : null,
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
);
|
||||
}),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
// Estimation du prix
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.primaryColor.withOpacity(0.08),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
backgroundColor: UnionFlowColors.background,
|
||||
body: Column(
|
||||
children: [
|
||||
OnboardingStepHeader(
|
||||
step: 2,
|
||||
total: 3,
|
||||
title: 'Période de facturation',
|
||||
subtitle: 'Choisissez votre rythme de paiement.\nPlus la période est longue, plus vous économisez.',
|
||||
),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.fromLTRB(20, 20, 20, 100),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('Estimation', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
Text(
|
||||
'${_prixEstime.toStringAsFixed(0)} FCFA',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: theme.primaryColor,
|
||||
// Rappel formule sélectionnée
|
||||
_FormulaRecap(
|
||||
codeFormule: widget.codeFormule,
|
||||
plage: widget.plage,
|
||||
prixMensuel: _formule?.prixMensuel ?? 0,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
OnboardingSectionTitle(
|
||||
icon: Icons.calendar_month_outlined,
|
||||
title: 'Choisissez votre période',
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
..._periodes.map((p) => _PeriodeCard(
|
||||
periode: p,
|
||||
selected: _selectedPeriode == p.code,
|
||||
prixTotal: _estimerPrix(p.code),
|
||||
onTap: () => setState(() => _selectedPeriode = p.code),
|
||||
)),
|
||||
const SizedBox(height: 24),
|
||||
// Total estimé
|
||||
Container(
|
||||
padding: const EdgeInsets.all(18),
|
||||
decoration: BoxDecoration(
|
||||
gradient: UnionFlowColors.primaryGradient,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: UnionFlowColors.greenGlowShadow,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.calculate_outlined,
|
||||
color: Colors.white70, size: 22),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Estimation indicative',
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(0.8),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
const Text(
|
||||
'Le montant exact est calculé par le système.',
|
||||
style: TextStyle(
|
||||
color: Colors.white70, fontSize: 11),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
_formatPrix(prixSelected),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w900,
|
||||
),
|
||||
),
|
||||
const Text(
|
||||
'FCFA',
|
||||
style:
|
||||
TextStyle(color: Colors.white70, fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// Note info
|
||||
Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: UnionFlowColors.infoPale,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: UnionFlowColors.info.withOpacity(0.2)),
|
||||
),
|
||||
child: const Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Icon(Icons.info_outline,
|
||||
color: UnionFlowColors.info, size: 18),
|
||||
SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Le type de votre organisation et le coefficient tarifaire exact sont déterminés lors de la création de votre compte. Le récapitulatif final vous montrera le montant précis.',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: UnionFlowColors.info,
|
||||
height: 1.4),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
context.read<OnboardingBloc>()
|
||||
..add(OnboardingPeriodeSelected(
|
||||
typePeriode: _selectedPeriode,
|
||||
typeOrganisation: _selectedTypeOrg,
|
||||
organisationId: _organisationId,
|
||||
))
|
||||
..add(const OnboardingDemandeConfirmee());
|
||||
},
|
||||
style: ElevatedButton.styleFrom(minimumSize: const Size.fromHeight(48)),
|
||||
child: const Text('Voir le récapitulatif'),
|
||||
),
|
||||
bottomNavigationBar: OnboardingBottomBar(
|
||||
enabled: true,
|
||||
label: 'Voir le récapitulatif',
|
||||
onPressed: () {
|
||||
context.read<OnboardingBloc>()
|
||||
..add(OnboardingPeriodeSelected(
|
||||
typePeriode: _selectedPeriode,
|
||||
typeOrganisation: '',
|
||||
organisationId: _organisationId,
|
||||
))
|
||||
..add(const OnboardingDemandeConfirmee());
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _formatPrix(double prix) {
|
||||
if (prix >= 1000000) return '${(prix / 1000000).toStringAsFixed(1)} M';
|
||||
if (prix >= 1000) {
|
||||
final parts = prix.toStringAsFixed(0);
|
||||
if (parts.length > 3) {
|
||||
return '${parts.substring(0, parts.length - 3)} ${parts.substring(parts.length - 3)}';
|
||||
}
|
||||
}
|
||||
return prix.toStringAsFixed(0);
|
||||
}
|
||||
}
|
||||
|
||||
class _StepIndicator extends StatelessWidget {
|
||||
final int current;
|
||||
final int total;
|
||||
const _StepIndicator({required this.current, required this.total});
|
||||
class _Periode {
|
||||
final String code, label, duree;
|
||||
final String? badge;
|
||||
final int nbMois;
|
||||
final double coef;
|
||||
const _Periode(this.code, this.label, this.duree, this.badge, this.nbMois, this.coef);
|
||||
}
|
||||
|
||||
class _FormulaRecap extends StatelessWidget {
|
||||
final String codeFormule;
|
||||
final String plage;
|
||||
final double prixMensuel;
|
||||
|
||||
const _FormulaRecap({
|
||||
required this.codeFormule,
|
||||
required this.plage,
|
||||
required this.prixMensuel,
|
||||
});
|
||||
|
||||
static const _plageLabels = {
|
||||
'PETITE': '1–100 membres',
|
||||
'MOYENNE': '101–500 membres',
|
||||
'GRANDE': '501–2 000 membres',
|
||||
'TRES_GRANDE': '2 000+ membres',
|
||||
};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: List.generate(total, (i) {
|
||||
final active = i + 1 <= current;
|
||||
return Expanded(
|
||||
child: Container(
|
||||
height: 4,
|
||||
margin: EdgeInsets.only(right: i < total - 1 ? 4 : 0),
|
||||
decoration: BoxDecoration(
|
||||
color: active ? Theme.of(context).primaryColor : Colors.grey[300],
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: UnionFlowColors.unionGreenPale,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: UnionFlowColors.unionGreen.withOpacity(0.25)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.check_circle_rounded,
|
||||
color: UnionFlowColors.unionGreen, size: 20),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
style: const TextStyle(
|
||||
color: UnionFlowColors.textPrimary, fontSize: 13),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: 'Formule $codeFormule',
|
||||
style: const TextStyle(fontWeight: FontWeight.w700),
|
||||
),
|
||||
const TextSpan(text: ' · '),
|
||||
TextSpan(
|
||||
text: _plageLabels[plage] ?? plage,
|
||||
style: const TextStyle(
|
||||
color: UnionFlowColors.textSecondary),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
Text(
|
||||
'${_formatPrix(prixMensuel)} FCFA/mois',
|
||||
style: const TextStyle(
|
||||
color: UnionFlowColors.unionGreen,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _formatPrix(double prix) {
|
||||
if (prix >= 1000) {
|
||||
final k = (prix / 1000).toStringAsFixed(0);
|
||||
return '$k 000';
|
||||
}
|
||||
return prix.toStringAsFixed(0);
|
||||
}
|
||||
}
|
||||
|
||||
class _PeriodeCard extends StatelessWidget {
|
||||
final _Periode periode;
|
||||
final bool selected;
|
||||
final double prixTotal;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const _PeriodeCard({
|
||||
required this.periode,
|
||||
required this.selected,
|
||||
required this.prixTotal,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
margin: const EdgeInsets.only(bottom: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: selected ? UnionFlowColors.unionGreenPale : UnionFlowColors.surface,
|
||||
border: Border.all(
|
||||
color: selected ? UnionFlowColors.unionGreen : UnionFlowColors.border,
|
||||
width: selected ? 2 : 1,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
boxShadow: selected ? UnionFlowColors.greenGlowShadow : UnionFlowColors.softShadow,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
selected ? Icons.check_circle_rounded : Icons.radio_button_unchecked,
|
||||
color: selected ? UnionFlowColors.unionGreen : UnionFlowColors.border,
|
||||
size: 22,
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
periode.label,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 15,
|
||||
color: selected
|
||||
? UnionFlowColors.unionGreen
|
||||
: UnionFlowColors.textPrimary,
|
||||
),
|
||||
),
|
||||
if (periode.badge != null) ...[
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: UnionFlowColors.successPale,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Text(
|
||||
periode.badge!,
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: UnionFlowColors.success,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
Text(
|
||||
periode.duree,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: UnionFlowColors.textSecondary),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
'~ ${_formatPrix(prixTotal)}',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w800,
|
||||
fontSize: 15,
|
||||
color: selected
|
||||
? UnionFlowColors.unionGreen
|
||||
: UnionFlowColors.textPrimary,
|
||||
),
|
||||
),
|
||||
const Text(
|
||||
'FCFA',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: UnionFlowColors.textSecondary),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _formatPrix(double prix) {
|
||||
if (prix >= 1000000) return '${(prix / 1000000).toStringAsFixed(1)} M';
|
||||
if (prix >= 1000) {
|
||||
final s = prix.toStringAsFixed(0);
|
||||
if (s.length > 3) {
|
||||
return '${s.substring(0, s.length - 3)} ${s.substring(s.length - 3)}';
|
||||
}
|
||||
}
|
||||
return prix.toStringAsFixed(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user