ente/lib/ui/payment/subscription_common_widgets.dart

127 lines
3.6 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:photos/models/subscription.dart';
2021-10-30 05:51:23 +00:00
import 'package:photos/ui/billing_questions_widget.dart';
import 'package:photos/utils/data_util.dart';
import 'package:photos/utils/date_time_util.dart';
class SubscriptionHeaderWidget extends StatefulWidget {
final bool isOnboarding;
final int currentUsage;
const SubscriptionHeaderWidget(
{Key key, this.isOnboarding, this.currentUsage})
: super(key: key);
@override
State<StatefulWidget> createState() {
return _SubscriptionHeaderWidgetState();
}
}
class _SubscriptionHeaderWidgetState extends State<SubscriptionHeaderWidget> {
@override
Widget build(BuildContext context) {
if (widget.isOnboarding) {
return Padding(
padding: const EdgeInsets.fromLTRB(20, 20, 20, 24),
child: Text(
"ente preserves your memories, so they're always available to you, even if you lose your device",
2022-05-16 20:52:10 +00:00
style: Theme.of(context).textTheme.caption
/*style: TextStyle(
color: Colors.white54,
height: 1.2,
2022-05-16 20:52:10 +00:00
)*/
,
),
);
} else {
return SizedBox(
2022-05-03 11:53:40 +00:00
height: 72,
2022-04-28 05:24:26 +00:00
width: double.infinity,
child: Padding(
2022-05-03 11:53:40 +00:00
padding: const EdgeInsets.all(24.0),
child: RichText(
text: TextSpan(
children: [
TextSpan(
text: "Current usage is ",
style: Theme.of(context).textTheme.subtitle1),
TextSpan(
text: formatBytes(widget.currentUsage),
style: Theme.of(context)
.textTheme
.subtitle1
.copyWith(fontWeight: FontWeight.bold),
)
],
),
),
),
);
}
}
}
class ValidityWidget extends StatelessWidget {
final Subscription currentSubscription;
const ValidityWidget({Key key, this.currentSubscription}) : super(key: key);
@override
Widget build(BuildContext context) {
if (currentSubscription == null) {
return Container();
}
var endDate = getDateAndMonthAndYear(
DateTime.fromMicrosecondsSinceEpoch(currentSubscription.expiryTime));
2022-04-28 05:24:26 +00:00
var message = "Renews on $endDate";
if (currentSubscription.productID == kFreeProductID) {
2022-05-16 20:52:10 +00:00
message = "Free plan valid till $endDate";
} else if (currentSubscription.attributes?.isCancelled ?? false) {
2022-04-28 05:24:26 +00:00
message = "Your subscription will be cancelled on $endDate";
}
2021-08-23 10:22:07 +00:00
return Padding(
padding: const EdgeInsets.only(top: 8),
child: Text(
message,
2022-04-28 05:24:26 +00:00
style: Theme.of(context).textTheme.caption,
),
);
}
}
class SubFaqWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Align(
alignment: Alignment.bottomCenter,
child: GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
showModalBottomSheet<void>(
backgroundColor: Color.fromRGBO(10, 15, 15, 1.0),
barrierColor: Colors.black87,
context: context,
builder: (context) {
return BillingQuestionsWidget();
},
);
},
child: Container(
padding: EdgeInsets.all(40),
child: RichText(
text: TextSpan(
2022-05-16 20:52:10 +00:00
text: "Questions?",
style: TextStyle(
color: Colors.blue,
fontFamily: 'Ubuntu',
),
),
),
),
),
);
}
}