changed premium directories to plus

This commit is contained in:
Kima
2024-04-07 19:59:38 +02:00
parent 6a7087d4f5
commit 23563bc4f9
35 changed files with 39 additions and 399 deletions

View File

@@ -0,0 +1,170 @@
import 'package:refilc/icons/filc_icons.dart';
import 'package:refilc_mobile_ui/plus/plus_screen.dart';
import 'package:refilc_plus/models/premium_scopes.dart';
import 'package:refilc_plus/providers/premium_provider.dart';
import 'package:refilc_plus/ui/mobile/plus/upsell.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:provider/provider.dart';
class ActiveSponsorCard extends StatelessWidget {
const ActiveSponsorCard({super.key});
static PremiumFeatureLevel? estimateLevel(List<String> scopes) {
if (scopes.contains(PremiumScopes.all) ||
scopes.contains(PremiumScopes.tierSponge)) {
return PremiumFeatureLevel.sponge;
}
if (scopes.contains(PremiumScopes.tierInk)) {
return PremiumFeatureLevel.ink;
}
if (scopes.contains(PremiumScopes.tierCap)) {
return PremiumFeatureLevel.cap;
}
return PremiumFeatureLevel.old;
}
IconData? _levelIcon(PremiumFeatureLevel level) {
switch (level) {
case PremiumFeatureLevel.cap:
return FilcIcons.kupak;
case PremiumFeatureLevel.ink:
return FilcIcons.tinta;
case PremiumFeatureLevel.sponge:
return FilcIcons.kupak;
case PremiumFeatureLevel.old:
return FilcIcons.kupak;
case PremiumFeatureLevel.basic:
return FilcIcons.kupak;
case PremiumFeatureLevel.gold:
return FilcIcons.kupak;
}
}
@override
Widget build(BuildContext context) {
final premium = Provider.of<PremiumProvider>(context, listen: false);
final level = estimateLevel(premium.scopes);
if (level == null) {
return const SizedBox();
}
Color? glow = Colors.white; //TODO: only temp fix kima (idk what but die)
switch (level) {
case PremiumFeatureLevel.cap:
glow = Colors.lightGreen;
break;
case PremiumFeatureLevel.ink:
glow = Colors.purple;
break;
case PremiumFeatureLevel.sponge:
glow = Colors.red;
break;
case PremiumFeatureLevel.old:
glow = Colors.red;
break;
case PremiumFeatureLevel.basic:
glow = Colors.red;
break;
case PremiumFeatureLevel.gold:
glow = Colors.red;
break;
}
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
boxShadow: [
BoxShadow(
color: glow.withOpacity(.4),
blurRadius: 42.0,
),
],
),
child: Card(
margin: EdgeInsets.zero,
elevation: 0,
color: const Color(0xff2B2B2B),
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(14.0)),
child: InkWell(
borderRadius: BorderRadius.circular(14.0),
splashColor: glow.withOpacity(.2),
onTap: () {
Navigator.of(context, rootNavigator: true)
.push(MaterialPageRoute(builder: (context) {
return const PlusScreen();
}));
},
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 12.0),
child: Row(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Stack(
children: [
CircleAvatar(
backgroundColor:
Theme.of(context).colorScheme.secondary,
backgroundImage: NetworkImage(
"https://github.com/${premium.login}.png?size=128"),
),
Positioned.fill(
child: Align(
alignment: Alignment.bottomRight,
child: Transform.translate(
offset: const Offset(3.0, 4.0),
child: Container(
padding: const EdgeInsets.all(4.0),
decoration: const BoxDecoration(
color: Color(0xff2B2B2B),
shape: BoxShape.circle,
),
child: const SizedBox(
height: 14.0,
width: 14.0,
),
),
),
),
),
Positioned.fill(
child: Align(
alignment: Alignment.bottomRight,
child: SvgPicture.asset(
"assets/images/github.svg",
height: 14.0,
),
),
),
],
),
),
Expanded(
child: Text(
premium.login,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 20,
color: Colors.white),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Icon(
_levelIcon(level),
color: Colors.white,
),
),
],
),
),
),
),
);
}
}

View File

@@ -0,0 +1,26 @@
import 'package:flutter/material.dart';
class AvatarStack extends StatelessWidget {
const AvatarStack({super.key, required this.children});
final List<Widget> children;
@override
Widget build(BuildContext context) {
return Stack(
children: [
if (children.isNotEmpty) children[0],
if (children.length > 1)
Transform.translate(
offset: const Offset(-20.0, 0.0),
child: children[1],
),
if (children.length > 2)
Transform.translate(
offset: const Offset(-40.0, 0.0),
child: children[2],
),
],
);
}
}

View File

@@ -0,0 +1,175 @@
// import 'package:refilc/api/client.dart';
// import 'package:refilc/theme/colors/colors.dart';
import 'package:refilc_plus/providers/premium_provider.dart';
// import 'package:refilc_plus/ui/mobile/plus/activation_view/activation_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'package:flutter_svg/svg.dart';
import 'package:provider/provider.dart';
class GithubLoginButton extends StatelessWidget {
const GithubLoginButton({super.key});
@override
Widget build(BuildContext context) {
final premium = Provider.of<PremiumProvider>(context);
return Card(
margin: EdgeInsets.zero,
elevation: 0,
color: const Color(0xFFC1CBDF),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0)),
child: InkWell(
borderRadius: BorderRadius.circular(14.0),
onTap: () async {
// if (premium.hasPremium) {
// premium.auth.refreshAuth(removePremium: true);
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(
// content: Text(
// "reFilc+ támogatás deaktiválva!",
// style: TextStyle(
// color: AppColors.of(context).text,
// fontWeight: FontWeight.bold,
// fontSize: 18.0),
// ),
// backgroundColor: Theme.of(context).scaffoldBackgroundColor,
// ));
// return;
// }
// Navigator.of(context).push(MaterialPageRoute(builder: (context) {
// return const PremiumActivationView();
// }));
// bool initFinished = await initPaymentSheet(context);
// if (initFinished) {
// stripe.PaymentSheetPaymentOption? result =
// await stripe.Stripe.instance.presentPaymentSheet();
// print(result == null);
// print(result?.label ?? 'nem label');
// }
// launchUrl(
// Uri.parse(
// 'https://api.refilc.hu/v3/payment/stripe-create-checkout?product=asdasd'),
// mode: LaunchMode.inAppBrowserView,
// );
},
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 12.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Stack(
children: [
SvgPicture.asset(
"assets/images/btn_github.svg",
height: 28.0,
),
Positioned.fill(
child: Align(
alignment: Alignment.bottomRight,
child: Transform.translate(
offset: const Offset(3.5, 4.6),
child: Container(
padding: const EdgeInsets.all(4.0),
decoration: const BoxDecoration(
color: Color(0xFFC1CBDF),
// color: Colors.red,
shape: BoxShape.circle,
),
child: const SizedBox(
height: 10.0,
width: 10.0,
),
),
),
),
),
Positioned.fill(
child: Align(
alignment: Alignment.bottomRight,
child: Transform.translate(
offset: const Offset(2.0, 2.0),
child: Icon(
premium.hasPremium
? FeatherIcons.minusCircle
: FeatherIcons.plusCircle,
color: const Color(0xFF243F76),
size: 14.0,
),
),
),
),
],
),
const SizedBox(
width: 18.0,
),
Text(
premium.hasPremium
? "Github szétkapcsolása"
: "Fiók összekötése Github-al",
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 18,
color: Color(0xFF243F76),
),
),
const SizedBox(
width: 4.0,
),
],
),
),
),
);
}
// Future<bool> initPaymentSheet(BuildContext context) async {
// try {
// // 1. create payment intent on the server
// final data = await _createPaymentSheet();
// if (data == null) {
// throw "API error, can't create payment sheet!";
// }
// // 2. initialize the payment sheet
// await stripe.Stripe.instance.initPaymentSheet(
// paymentSheetParameters: stripe.SetupPaymentSheetParameters(
// // Set to true for custom flow
// customFlow: false,
// // Main params
// merchantDisplayName: 'reFilc',
// paymentIntentClientSecret: data['paymentIntent'],
// // Customer keys
// customerEphemeralKeySecret: data['ephemeralKey'],
// customerId: data['customer'],
// // Extra options
// // applePay: const stripe.PaymentSheetApplePay(
// // merchantCountryCode: 'HU',
// // ),
// googlePay: const stripe.PaymentSheetGooglePay(
// merchantCountryCode: 'HU',
// testEnv: true,
// ),
// style: ThemeMode.system,
// ),
// );
// return true;
// } catch (e) {
// // ignore: use_build_context_synchronously
// ScaffoldMessenger.of(context).showSnackBar(
// SnackBar(content: Text('Error: $e')),
// );
// rethrow;
// }
// }
// Future<Map?> _createPaymentSheet() async {
// Map? data = await FilcAPI.createPaymentSheet("refilcplus");
// return data;
// }
}

View File

@@ -0,0 +1,52 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
class GithubCard extends StatelessWidget {
const GithubCard({super.key, this.onPressed});
final void Function()? onPressed;
@override
Widget build(BuildContext context) {
return Card(
margin: EdgeInsets.zero,
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14.0)),
color: const Color(0xff2B2B2B),
child: Material(
type: MaterialType.transparency,
child: InkWell(
borderRadius: BorderRadius.circular(14.0),
onTap: onPressed,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0).add(const EdgeInsets.only(top: 4.0)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
const Expanded(
child: Text(
"Támogass minket Githubon, hogy megszerezd a jutalmakat!",
style: TextStyle(color: Colors.white),
),
),
SvgPicture.asset("assets/images/github.svg"),
],
),
const SizedBox(height: 4.0),
Chip(
backgroundColor: Colors.black.withOpacity(.5),
label: const Text(
"Már támogatsz? Jelentkezz be!",
style: TextStyle(color: Colors.white),
),
),
],
),
),
),
),
);
}
}

View File

@@ -0,0 +1,107 @@
import 'package:refilc/theme/colors/colors.dart';
import 'package:refilc_plus/providers/premium_provider.dart';
// import 'package:refilc_plus/ui/mobile/plus/activation_view/activation_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'package:flutter_svg/svg.dart';
import 'package:provider/provider.dart';
class GithubConnectButton extends StatelessWidget {
const GithubConnectButton({super.key});
@override
Widget build(BuildContext context) {
final premium = Provider.of<PremiumProvider>(context);
return Card(
margin: EdgeInsets.zero,
elevation: 0,
color: const Color(0xff2B2B2B),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14.0)),
child: InkWell(
borderRadius: BorderRadius.circular(14.0),
onTap: () {
if (premium.hasPremium) {
premium.auth.refreshAuth(removePremium: true);
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(
"Prémium deaktiválva.",
style: TextStyle(
color: AppColors.of(context).text,
fontWeight: FontWeight.bold,
fontSize: 18.0),
),
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
));
return;
}
// Navigator.of(context).push(MaterialPageRoute(builder: (context) {
// // return const PremiumActivationView();
// }));
},
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 12.0),
child: Row(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Stack(
children: [
SvgPicture.asset(
"assets/images/github.svg",
height: 32.0,
),
Positioned.fill(
child: Align(
alignment: Alignment.bottomRight,
child: Transform.translate(
offset: const Offset(3.0, 4.0),
child: Container(
padding: const EdgeInsets.all(4.0),
decoration: const BoxDecoration(
color: Color(0xff2B2B2B),
shape: BoxShape.circle,
),
child: const SizedBox(
height: 14.0,
width: 14.0,
),
),
),
),
),
Positioned.fill(
child: Align(
alignment: Alignment.bottomRight,
child: Transform.translate(
offset: const Offset(2.0, 2.0),
child: Icon(
premium.hasPremium
? FeatherIcons.minusCircle
: FeatherIcons.plusCircle,
color: Colors.white,
size: 16.0,
),
),
),
),
],
),
),
Text(
premium.hasPremium
? "GitHub szétkapcsolása"
: "GitHub csatlakoztatása",
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 20,
color: Colors.white),
),
],
),
),
),
);
}
}

View File

@@ -0,0 +1,80 @@
import 'dart:ui';
import 'package:flutter/material.dart';
class PremiumGoalCard extends StatelessWidget {
const PremiumGoalCard({super.key, this.progress = 100, this.target = 1});
final double progress;
final double target;
@override
Widget build(BuildContext context) {
return Card(
margin: EdgeInsets.zero,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Cél: ${target.round()} támogató",
style:
const TextStyle(fontWeight: FontWeight.bold, fontSize: 18.0),
),
const SizedBox(height: 8.0),
Stack(
alignment: Alignment.center,
children: [
Container(
height: 12,
decoration: BoxDecoration(
color: Colors.black.withOpacity(.2),
borderRadius: BorderRadius.circular(45.0),
),
),
LayoutBuilder(
builder: (context, size) {
return Align(
alignment: Alignment.centerLeft,
child: Row(
children: [
Container(
height: 12,
width: size.maxWidth * (progress / 100),
decoration: BoxDecoration(
gradient: const LinearGradient(colors: [
Color(0xFFFF2A9D),
Color(0xFFFF37F7)
]),
borderRadius: BorderRadius.circular(45.0),
),
),
Transform.translate(
offset: const Offset(-15.0, 0),
child: Stack(
children: [
ImageFiltered(
imageFilter:
ImageFilter.blur(sigmaX: 5, sigmaY: 5),
child: Image.asset("assets/images/heart.png",
color: Colors.black.withOpacity(.3)),
),
Image.asset("assets/images/heart.png"),
],
),
),
],
),
);
},
),
],
),
],
),
),
);
}
}

View File

@@ -0,0 +1,253 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:refilc_plus/providers/premium_provider.dart';
import 'package:refilc_plus/ui/mobile/plus/activation_view/activation_view.dart';
import 'package:refilc_mobile_ui/plus/plus_screen.i18n.dart';
import 'package:url_launcher/url_launcher.dart';
class PlusPlanCard extends StatelessWidget {
const PlusPlanCard({
super.key,
required this.iconPath,
required this.title,
required this.description,
required this.color,
required this.gradient,
this.price = 0,
required this.id,
this.active = false,
this.borderRadius,
this.features = const [],
});
final String iconPath;
final String title;
final String description;
final Color color;
final LinearGradient gradient;
final double price;
final String id;
final bool active;
final BorderRadiusGeometry? borderRadius;
final List<List<String>> features;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
if (Provider.of<PremiumProvider>(context, listen: false).hasPremium) {
if (!active) {
launchUrl(
Uri.parse(
'https://billing.stripe.com/p/login/5kAbJXeMkaRi8dWeUU'),
mode: LaunchMode.inAppBrowserView,
);
}
return;
}
Navigator.of(context).push(MaterialPageRoute(builder: (context) {
return PremiumActivationView(product: id);
}));
},
child: Container(
decoration: BoxDecoration(
gradient: gradient,
borderRadius: borderRadius!.add(BorderRadius.circular(1.5)),
),
padding: const EdgeInsets.all(1.5),
child: Card(
margin: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: borderRadius!,
),
shadowColor: Colors.transparent,
surfaceTintColor: Colors.white,
color: Colors.white.withOpacity(0.9),
child: Padding(
padding: const EdgeInsets.only(
top: 18.0, bottom: 16.0, left: 22.0, right: 18.0),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Image.asset(
iconPath,
width: iconPath.endsWith('ink.png') ? 29.0 : 25.0,
height: 25.0,
),
const SizedBox(
width: 12.0,
),
Text(
title,
style: const TextStyle(
fontSize: 22.0,
color: Color(0xFF0B0B0B),
fontWeight: FontWeight.w600,
height: 1.2,
),
),
],
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
gradient: active
? const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color.fromARGB(255, 196, 213, 253),
Color.fromARGB(255, 227, 235, 250),
Color.fromARGB(255, 214, 226, 250),
],
)
: const LinearGradient(
colors: [
Color(0xFFEFF4FE),
Color(0xFFEFF4FE),
],
),
),
padding: const EdgeInsets.all(2.0),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
color: const Color(0xFFEFF4FE),
),
padding: const EdgeInsets.symmetric(
horizontal: 10.0, vertical: 2.0),
child: Text(
active
? 'active'.i18n
: '${price.toStringAsFixed(2).replaceAll('.', ',')}',
style: const TextStyle(
fontSize: 16.6,
color: Color(0xFF243F76),
fontWeight: FontWeight.w600,
),
),
),
),
],
),
const SizedBox(
height: 12.0,
),
Text(
description,
style: TextStyle(
color: const Color(0xFF011234).withOpacity(0.6),
fontSize: 13.69,
fontWeight: FontWeight.w500,
),
),
const SizedBox(
height: 14.20,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: features
.map((e) => Column(
children: [
const SizedBox(
height: 10.0,
),
Row(
children: [
SizedBox(
width: 22.22,
child: Text(
e[0],
style: const TextStyle(fontSize: 18.0),
),
),
const SizedBox(
width: 14.0,
),
Expanded(
child: e[1].endsWith('tier_benefits')
? Text.rich(
style: const TextStyle(
height: 1.2,
fontWeight: FontWeight.w500,
color: Color(0xFF011234),
fontSize: 13.69,
),
TextSpan(
children: [
TextSpan(
text: 'every'.i18n,
),
e[1].startsWith('cap')
? const TextSpan(
text: 'reFilc+',
style: TextStyle(
color:
Color(0xFF7C3EFF),
fontWeight:
FontWeight.w600,
),
)
: TextSpan(
children: [
const TextSpan(
text: 'reFilc+',
style: TextStyle(
color: Color(
0xFF7C3EFF),
fontWeight:
FontWeight
.w600,
),
),
TextSpan(
text: 'and'.i18n,
),
const TextSpan(
text:
'reFilc+ Gold',
style: TextStyle(
color: Color(
0xFF0061BB),
fontWeight:
FontWeight
.w600,
),
),
],
),
TextSpan(text: 'benefit'.i18n),
],
),
)
: Text(
e[1],
maxLines: 2,
style: const TextStyle(
height: 1.2,
color: Color(0xFF011234),
fontWeight: FontWeight.w500,
fontSize: 13.69,
),
),
),
],
),
],
))
.toList(),
),
],
),
),
),
),
);
}
}

View File

@@ -0,0 +1,79 @@
import 'package:flutter/material.dart';
class PremiumRewardCard extends StatelessWidget {
const PremiumRewardCard(
{super.key,
this.imageKey,
this.icon,
this.title,
this.description,
this.soon = false});
final String? imageKey;
final Widget? icon;
final Widget? title;
final Widget? description;
final bool soon;
@override
Widget build(BuildContext context) {
return Card(
margin: EdgeInsets.zero,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (soon)
const Padding(
padding: EdgeInsets.only(left: 8.0),
child: Chip(
labelPadding: EdgeInsets.zero,
padding: EdgeInsets.symmetric(horizontal: 12.0),
backgroundColor: Color(0x777645D3),
label: Text("Hamarosan",
style: TextStyle(fontWeight: FontWeight.w500)),
),
),
if (imageKey != null)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 14.0)
.add(EdgeInsets.only(bottom: 12.0, top: soon ? 0 : 14.0)),
child: Image.asset("assets/images/${imageKey!}.png"),
)
else
const SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: Row(
children: [
if (icon != null) ...[icon!, const SizedBox(width: 12.0)],
if (title != null)
Expanded(
child: DefaultTextStyle(
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(fontWeight: FontWeight.w700, fontSize: 20),
child: title!,
),
),
],
),
),
if (description != null)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0)
.add(const EdgeInsets.only(top: 4.0, bottom: 12.0)),
child: DefaultTextStyle(
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(fontSize: 16),
child: description!,
),
),
],
),
);
}
}

View File

@@ -0,0 +1,35 @@
import 'package:refilc/models/supporter.dart';
import 'package:flutter/material.dart';
class SupporterChip extends StatelessWidget {
const SupporterChip({super.key, required this.supporter});
final Supporter supporter;
@override
Widget build(BuildContext context) {
return Chip(
side: BorderSide.none,
shape: const StadiumBorder(side: BorderSide.none),
padding: const EdgeInsets.all(8.0),
avatar: supporter.avatar != ""
? CircleAvatar(
backgroundColor: Theme.of(context).colorScheme.secondary,
backgroundImage: NetworkImage(supporter.avatar),
)
: null,
labelPadding: const EdgeInsets.only(left: 12.0, right: 8.0),
label: Text.rich(
TextSpan(children: [
TextSpan(text: supporter.name),
if (supporter.type == DonationType.once)
TextSpan(
text: " \$${supporter.price}",
style: const TextStyle(fontWeight: FontWeight.w400),
),
]),
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0),
),
);
}
}

View File

@@ -0,0 +1,79 @@
import 'package:refilc/models/supporter.dart';
import 'package:refilc_mobile_ui/plus/components/supporter_chip.dart';
import 'package:refilc_mobile_ui/plus/components/supporter_tile.dart';
import 'package:flutter/material.dart';
class SupporterGroupCard extends StatelessWidget {
const SupporterGroupCard({
super.key,
this.title,
this.icon,
this.expanded = false,
this.supporters = const [],
this.glow,
});
final Widget? icon;
final Widget? title;
final bool expanded;
final List<Supporter> supporters;
final Color? glow;
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
boxShadow: [
if (glow != null)
BoxShadow(
color: glow!.withOpacity(.2),
blurRadius: 60.0,
),
],
),
child: Card(
margin: EdgeInsets.zero,
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
if (icon != null) ...[icon!, const SizedBox(width: 12.0)],
if (title != null)
Expanded(
child: DefaultTextStyle(
style: Theme.of(context)
.textTheme
.titleLarge!
.copyWith(fontWeight: FontWeight.w700),
child: title!,
),
),
],
),
const SizedBox(height: 12.0),
if (expanded)
Column(
children: supporters
.map((e) => SupporterTile(supporter: e))
.toList(),
)
else
Wrap(
spacing: 8.0,
children: supporters
.map((e) => SupporterChip(supporter: e))
.toList(),
),
],
),
),
),
);
}
}

View File

@@ -0,0 +1,23 @@
import 'package:refilc/models/supporter.dart';
import 'package:flutter/material.dart';
class SupporterTile extends StatelessWidget {
const SupporterTile({super.key, required this.supporter});
final Supporter supporter;
@override
Widget build(BuildContext context) {
return ListTile(
contentPadding: EdgeInsets.zero,
leading: CircleAvatar(
backgroundImage: NetworkImage(supporter.avatar),
),
title: Text(
supporter.name,
style: const TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Text(supporter.comment),
);
}
}

View File

@@ -0,0 +1,82 @@
import 'dart:math';
import 'package:refilc/models/supporter.dart';
import 'package:refilc_mobile_ui/plus/components/avatar_stack.dart';
import 'package:refilc_mobile_ui/plus/supporters_screen.dart';
import 'package:flutter/material.dart';
class SupportersButton extends StatelessWidget {
const SupportersButton({super.key, required this.supporters});
final Future<Supporters?> supporters;
@override
Widget build(BuildContext context) {
return Card(
shape: const StadiumBorder(),
margin: EdgeInsets.zero,
child: InkWell(
customBorder: const StadiumBorder(),
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => SupportersScreen(supporters: supporters)),
);
},
child: Container(
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 14.0),
child: Row(
children: [
const Expanded(
child: Text(
"Köszönjük, támogatók!",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17.0),
),
),
FutureBuilder<Supporters?>(
future: supporters,
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const SizedBox();
}
final sponsors = snapshot.data!.github
.where((e) => e.type == DonationType.monthly)
.toList();
sponsors.shuffle(Random(
(DateTime.now().millisecondsSinceEpoch /
1000 /
60 /
60 /
24)
.floor()));
return AvatarStack(
children: [
// ignore: prefer_is_empty
if (sponsors.length > 0 && sponsors[0].avatar != "")
CircleAvatar(
backgroundColor:
Theme.of(context).colorScheme.secondary,
backgroundImage: NetworkImage(sponsors[0].avatar),
),
if (sponsors.length > 1 && sponsors[1].avatar != "")
CircleAvatar(
backgroundColor:
Theme.of(context).colorScheme.secondary,
backgroundImage: NetworkImage(sponsors[1].avatar),
),
if (sponsors.length > 2 && sponsors[2].avatar != "")
CircleAvatar(
backgroundColor:
Theme.of(context).colorScheme.secondary,
backgroundImage: NetworkImage(sponsors[2].avatar),
),
],
);
}),
],
),
),
),
);
}
}