@@ -21,78 +21,76 @@ class OfferCubit extends Cubit<OfferState> {
2121 void _fetchItems () {
2222 emit (LoadingOfferState ());
2323
24- CombineLatestStream .combine6 (
24+ CombineLatestStream .combine7 (
2525 _sponsorshipRepository.get (),
26- _productRepository.get ('app.tankste.sponsor.sub.yearly.12 ' ),
27- _productRepository.get ('app.tankste.sponsor.sub.monthly.2 ' ),
26+ _productRepository.get ('app.tankste.sponsor.product.50 ' ),
27+ _productRepository.get ('app.tankste.sponsor.product.20 ' ),
2828 _productRepository.get ('app.tankste.sponsor.product.10' ),
29+ _productRepository.get ('app.tankste.sponsor.product.5' ),
2930 _productRepository.get ('app.tankste.sponsor.product.2' ),
3031 _productRepository.get ('app.tankste.sponsor.product.1' ),
3132 (sponsorshipResult,
32- yearlySubscriptionProductResult ,
33- monthlySubscriptionProductResult ,
33+ onceFiftyProductResult ,
34+ onceTwentyProductResult ,
3435 onceTenProductResult,
36+ onceFiveProductResult,
3537 onceTwoProductResult,
3638 onceOneProductResult) {
3739 return sponsorshipResult.when ((sponsorship) {
38- return yearlySubscriptionProductResult.when (
39- (yearlySubscriptionProduct) {
40- return monthlySubscriptionProductResult.when (
41- (monthlySubscriptionProduct) {
40+ return onceFiftyProductResult.when ((onceFiftyProduct) {
41+ return onceTwentyProductResult.when ((onceTwentyProduct) {
4242 return onceTenProductResult.when ((onceTenProduct) {
43- return onceTwoProductResult.when ((onceTwoProduct) {
44- return onceOneProductResult.when ((onceOneProduct) {
45- List <OfferItem > items = [];
46- if (sponsorship.activeSubscriptionId == null ) {
47- items.add (OfferItem (
48- id: yearlySubscriptionProduct.id,
49- labelPrice: yearlySubscriptionProduct.priceLabel,
50- labelType: tr ('sponsor.overview.options.year.by' ),
51- hint: tr ('sponsor.overview.options.year.hint' , args: [yearlySubscriptionProduct.priceLabel])));
52-
53- items.add (OfferItem (
54- id: monthlySubscriptionProduct.id,
55- labelPrice: monthlySubscriptionProduct.priceLabel,
56- labelType: tr ('sponsor.overview.options.month.by' ),
57- hint: tr ('sponsor.overview.options.month.hint' , args: [monthlySubscriptionProduct.priceLabel])));
58-
59- items.add (OfferItem (
60- id: onceTenProduct.id,
61- labelPrice: onceTenProduct.priceLabel,
62- labelType: tr ('sponsor.overview.options.single.by' ),
63- hint: tr ('sponsor.overview.options.single.hint' , args: [onceTenProduct.priceLabel])));
64-
65- items.add (OfferItem (
66- id: onceTwoProduct.id,
67- labelPrice: onceTwoProduct.priceLabel,
68- labelType: tr ('sponsor.overview.options.single.by' ),
69- hint: tr ('sponsor.overview.options.single.hint' , args: [onceTwoProduct.priceLabel])));
70-
71- items.add (OfferItem (
72- id: onceOneProduct.id,
73- labelPrice: onceOneProduct.priceLabel,
74- labelType: tr ('sponsor.overview.options.single.by' ),
75- hint: tr ('sponsor.overview.options.single.hint' , args: [onceOneProduct.priceLabel])));
76- }
77-
78- return OffersOfferState (
79- title: sponsorship.activeSubscriptionId != null
80- ? tr ('sponsor.overview.options.title.extended' )
81- : tr ('sponsor.overview.options.title.new' ),
82- isSponsorshipInfoVisible: sponsorship.value > 0 ,
83- sponsoredValue: "${sponsorship .value .round ()} €" ,
84- activeSubscription:
85- sponsorship.activeSubscriptionId != null
86- ? [
87- yearlySubscriptionProduct,
88- monthlySubscriptionProduct
89- ]
90- .firstWhereOrNull ((element) =>
91- element.id ==
92- sponsorship.activeSubscriptionId)
93- ? .title
94- : null ,
95- items: items);
43+ return onceFiveProductResult.when ((onceFiveProduct) {
44+ return onceTwoProductResult.when ((onceTwoProduct) {
45+ return onceOneProductResult.when ((onceOneProduct) {
46+ List <OfferItem > items = [
47+ OfferItem (
48+ id: onceFiftyProduct.id,
49+ labelPrice: onceFiftyProduct.priceLabel,
50+ labelType: tr ('sponsor.overview.options.single.by' ),
51+ hint: tr ('sponsor.overview.options.single.hint' ,
52+ args: [onceFiftyProduct.priceLabel])),
53+ OfferItem (
54+ id: onceTwentyProduct.id,
55+ labelPrice: onceTwentyProduct.priceLabel,
56+ labelType: tr ('sponsor.overview.options.single.by' ),
57+ hint: tr ('sponsor.overview.options.single.hint' ,
58+ args: [onceTwentyProduct.priceLabel])),
59+ OfferItem (
60+ id: onceTenProduct.id,
61+ labelPrice: onceTenProduct.priceLabel,
62+ labelType: tr ('sponsor.overview.options.single.by' ),
63+ hint: tr ('sponsor.overview.options.single.hint' ,
64+ args: [onceTenProduct.priceLabel])),
65+ OfferItem (
66+ id: onceFiveProduct.id,
67+ labelPrice: onceFiveProduct.priceLabel,
68+ labelType: tr ('sponsor.overview.options.single.by' ),
69+ hint: tr ('sponsor.overview.options.single.hint' ,
70+ args: [onceFiveProduct.priceLabel])),
71+ OfferItem (
72+ id: onceTwoProduct.id,
73+ labelPrice: onceTwoProduct.priceLabel,
74+ labelType: tr ('sponsor.overview.options.single.by' ),
75+ hint: tr ('sponsor.overview.options.single.hint' ,
76+ args: [onceTwoProduct.priceLabel])),
77+ OfferItem (
78+ id: onceOneProduct.id,
79+ labelPrice: onceOneProduct.priceLabel,
80+ labelType: tr ('sponsor.overview.options.single.by' ),
81+ hint: tr ('sponsor.overview.options.single.hint' ,
82+ args: [onceOneProduct.priceLabel])),
83+ ];
84+
85+ return OffersOfferState (
86+ title: tr ('sponsor.overview.options.title.new' ),
87+ isSponsorshipInfoVisible: sponsorship.value > 0 ,
88+ sponsoredValue: "${sponsorship .value .round ()} €" ,
89+ activeSubscription: null ,
90+ items: items);
91+ },
92+ (error) =>
93+ ErrorOfferState (errorDetails: error.toString ()));
9694 }, (error) => ErrorOfferState (errorDetails: error.toString ()));
9795 }, (error) => ErrorOfferState (errorDetails: error.toString ()));
9896 }, (error) => ErrorOfferState (errorDetails: error.toString ()));
0 commit comments