import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:mnemo_cards_common/mnemo_cards_common.dart'; import 'package:mnemo_cards_frontend_common/mnemo_cards_frontend_common.dart'; import 'package:url_launcher/url_launcher_string.dart'; import 'package:mnemo_cards/utils/string_helper.dart'; import '../../theme/themes.dart'; class SubscriptionPage extends StatelessWidget { final SubscriptionPageDto dto; SubscriptionPage(this.dto); @override Widget build(BuildContext context) { return Scaffold( body: Column( children: [ Header(dto.title, hasPopButton: true, center: true), ...dto.items.build(), ...dto.plans.map(_SubscriptionPlanWidget.new), BigBackButton(), ], ), ); } } class _SubscriptionPlanWidget extends StatelessWidget { final SubscriptionPlanDto plan; _SubscriptionPlanWidget(this.plan); @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.only(left: 10.0, right: 10.0), height: (90 + (plan.tip == null ? 0 : 13)).h, child: GestureDetector( onTap: () => plan.deeplink?.let((d) => launchUrlString(d)), child: Stack( alignment: Alignment.topCenter, children: [ Padding( padding: EdgeInsets.only(top: plan.tip == null ? 0 : 13.h), child: Container( height: 80.h, decoration: BoxDecoration( color: Theme.of(context).scaffoldBackgroundColor, border: Border.all(color: borderGray), borderRadius: BorderRadius.circular(12.0), ), padding: EdgeInsets.only( left: 10.0.w, right: 20.w, top: 10.h, bottom: 10.h, ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded(child: _lead(plan)), SizedBox( width: 85.w, child: _trail(plan), ), ], ), ), ), if (plan.tip != null) Container( height: 26.h, width: 110.w, alignment: Alignment.center, decoration: BoxDecoration( color: plan.tipColor?.asColor ?? progressBlue, border: Border.all(color: borderGray), borderRadius: BorderRadius.circular(16.0), ), padding: EdgeInsets.all(2.0.w), child: Text( plan.tip!, style: TextStyle(color: white), ), ), ], ), ), ); } Widget _lead(SubscriptionPlanDto plan) { return Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text.rich( TextSpan( children: [ if (plan.titleLead != null) TextSpan( text: plan.titleLead, style: TextStyle(fontSize: 32), ), if (plan.title != null) TextSpan( text: ' ${plan.title}', style: TextStyle( fontSize: 16, ), ), ], style: TextStyle( height: 0.85, )), ), Text.rich( TextSpan( children: [ if (plan.subtitleCrossed != null) TextSpan( text: plan.subtitleCrossed, style: TextStyle( fontSize: 20, color: borderGray, decoration: TextDecoration.lineThrough, height: 0.85, ), ), if (plan.subtitleCrossed != null && plan.subtitle != null) TextSpan(text: ' '), if (plan.subtitle != null) TextSpan( text: plan.subtitle, style: TextStyle( fontSize: 20.h, height: 0.85, ), ), ], ), ) ], ); } Widget _trail(SubscriptionPlanDto plan) { if (plan.pricePerMonth != null) return Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.end, children: [ Text.rich( TextSpan(children: [ TextSpan( text: plan.pricePerMonth!, style: TextStyle(fontSize: 24), ), TextSpan( text: ' ${plan.currency}', style: TextStyle( fontSize: 14, ), ), ], style: TextStyle(height: 0.85)), ), Text( 'в месяц', style: TextStyle( fontSize: 14, ), ), ], ); return SizedBox.shrink(); } }