init refilc-plus

This commit is contained in:
skidoodle 2024-10-03 18:47:25 +02:00
commit 6edc2029bd
Signed by: albert
GPG key ID: A06E3070D7D55BF2
37 changed files with 6988 additions and 0 deletions

View file

@ -0,0 +1,201 @@
import 'package:refilc/theme/colors/colors.dart';
import 'package:refilc_plus/providers/plus_provider.dart';
import 'package:flutter/material.dart';
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
class ActivationDashboard extends StatefulWidget {
const ActivationDashboard({super.key});
@override
State<ActivationDashboard> createState() => _ActivationDashboardState();
}
class _ActivationDashboardState extends State<ActivationDashboard> {
bool manualActivationLoading = false;
Future<void> onManualActivation() async {
final data = await Clipboard.getData("text/plain");
if (data == null || data.text == null || data.text == "") {
return;
}
setState(() {
manualActivationLoading = true;
});
final result =
// ignore: use_build_context_synchronously
await context.read<PlusProvider>().auth.finishAuth(data.text!);
setState(() {
manualActivationLoading = false;
});
if (!result && mounted) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text(
"Sikertelen aktiválás. Kérlek próbáld újra később!",
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
backgroundColor: Colors.red,
));
}
}
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Spacer(),
Center(
child: Image.asset(
"assets/icons/ic_rounded.png",
height: 64.0,
),
// child: SvgPicture.asset(
// "assets/images/github.svg",
// height: 64.0,
// ),
),
const SizedBox(height: 32.0),
const Text(
"Válassz fizetési módot, majd folytasd a fizetést a Stripe felületén, hogy aktiváld az előfizetésed.",
textAlign: TextAlign.center,
style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18.0),
),
// const SizedBox(height: 12.0),
// Card(
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(14.0)),
// child: const Padding(
// padding: EdgeInsets.all(16.0),
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Row(
// children: [
// Icon(FeatherIcons.alertTriangle,
// size: 20.0, color: Colors.orange),
// SizedBox(width: 12.0),
// Text(
// "Figyelem!",
// style: TextStyle(
// fontSize: 18.0, fontWeight: FontWeight.bold),
// ),
// ],
// ),
// SizedBox(height: 6.0),
// Text(
// "Az automatikus visszairányítás az alkalmazásba nem mindig működik. Ebben az esetben kérjük nyomd meg lent a \"Manuális aktiválás\" gombot!",
// style: TextStyle(fontSize: 16.0),
// ),
// ],
// ),
// ),
// ),
const SizedBox(height: 12.0),
Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14.0)),
child: const Padding(
padding: EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(FeatherIcons.alertTriangle,
size: 20.0, color: Colors.orange),
SizedBox(width: 12.0),
Text(
"Figyelem!",
style: TextStyle(
fontSize: 18.0, fontWeight: FontWeight.bold),
),
],
),
SizedBox(height: 6.0),
Text(
"Az aktiválás azonnal történik, amint kifizetted a szolgáltatás díját. A szolgáltatás automatikusan megújul, lemondásra a beállításokban lesz lehetőséget.",
style: TextStyle(fontSize: 16.0),
),
],
),
),
),
const SizedBox(height: 12.0),
Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14.0)),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
"Ha fizetés után a Stripe nem irányít vissza az alkalmazásba automatikusan, aktiválhatod a támogatásod a munkamenet azonosítóval, melyet kimásolhatsz a hibás URL \"session_id\" paraméteréből.",
style:
TextStyle(fontSize: 15.0, fontWeight: FontWeight.w500),
),
const SizedBox(height: 6.0),
Center(
child: TextButton.icon(
onPressed: onManualActivation,
style: ButtonStyle(
foregroundColor: WidgetStatePropertyAll(
Theme.of(context).colorScheme.secondary),
overlayColor: WidgetStatePropertyAll(Theme.of(context)
.colorScheme
.secondary
.withOpacity(.1)),
),
icon: manualActivationLoading
? const SizedBox(
height: 16.0,
width: 16.0,
child: CircularProgressIndicator(),
)
: const Icon(FeatherIcons.key, size: 20.0),
label: const Padding(
padding: EdgeInsets.only(left: 8.0),
child: Text(
"Aktiválás azonosítóval",
style: TextStyle(fontSize: 16.0),
),
),
),
),
],
),
),
),
const Spacer(),
Padding(
padding: const EdgeInsets.only(bottom: 24.0),
child: Center(
child: TextButton.icon(
onPressed: () {
Navigator.of(context).pop();
},
style: ButtonStyle(
foregroundColor:
WidgetStatePropertyAll(AppColors.of(context).text),
overlayColor: WidgetStatePropertyAll(
AppColors.of(context).text.withOpacity(.1)),
),
icon: const Icon(FeatherIcons.arrowLeft, size: 20.0),
label: const Text(
"Vissza",
style: TextStyle(fontSize: 16.0),
),
),
),
),
],
),
);
}
}

View file

@ -0,0 +1,97 @@
import 'package:animations/animations.dart';
import 'package:refilc/theme/colors/colors.dart';
import 'package:refilc_plus/providers/plus_provider.dart';
import 'package:refilc_plus/ui/mobile/plus/activation_view/activation_dashboard.dart';
import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';
import 'package:provider/provider.dart';
import 'package:refilc_plus/ui/mobile/plus/plus_things.i18n.dart';
class PremiumActivationView extends StatefulWidget {
const PremiumActivationView({super.key, required this.product});
final String product;
@override
State<PremiumActivationView> createState() => _PremiumActivationViewState();
}
class _PremiumActivationViewState extends State<PremiumActivationView>
with SingleTickerProviderStateMixin {
late AnimationController animation;
bool activated = false;
@override
void initState() {
super.initState();
context.read<PlusProvider>().auth.initAuth(product: widget.product);
animation =
AnimationController(vsync: this, duration: const Duration(seconds: 2));
}
@override
void dispose() {
animation.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final premium = context.watch<PlusProvider>();
if (premium.hasPremium && !activated) {
activated = true;
animation.forward();
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
Future.delayed(const Duration(seconds: 5)).then((value) {
if (mounted) {
// pop the anim
Navigator.of(context).pop();
// pop the plus view
Navigator.of(context).pop();
// show alert to save code
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
"copy_code_asap".i18n,
textAlign: TextAlign.center,
style: TextStyle(
color: AppColors.of(context).text,
fontWeight: FontWeight.w600,
),
),
backgroundColor: AppColors.of(context).background,
),
);
}
});
});
}
return Scaffold(
body: PageTransitionSwitcher(
transitionBuilder: (child, primaryAnimation, secondaryAnimation) =>
SharedAxisTransition(
animation: primaryAnimation,
secondaryAnimation: secondaryAnimation,
transitionType: SharedAxisTransitionType.horizontal,
fillColor: Colors.transparent,
child: child,
),
child: premium.hasPremium
? Center(
child: SizedBox(
width: 400,
child: Lottie.network(
"https://assets2.lottiefiles.com/packages/lf20_wkebwzpz.json",
controller: animation,
),
),
)
: const SafeArea(child: ActivationDashboard()),
),
);
}
}