Refactor: Code display in separate widget

This commit is contained in:
Neeraj Gupta 2023-02-23 08:42:58 +05:30
parent 3a24c43bd3
commit 90cad06cde
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1
2 changed files with 51 additions and 36 deletions

View file

@ -0,0 +1,49 @@
import "package:dotted_border/dotted_border.dart";
import "package:flutter/material.dart";
import "package:photos/theme/ente_theme.dart";
// Figma: https://www.figma.com/file/SYtMyLBs5SAOkTbfMMzhqt/ente-Visual-Design?node-id=11219%3A62974&t=BRCLJhxXP11Q3Wyw-0
class ReferralCodeWidget extends StatelessWidget {
final String codeValue;
const ReferralCodeWidget(this.codeValue, {Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final colorScheme = getEnteColorScheme(context);
final textStyle = getEnteTextTheme(context);
return Center(
child: DottedBorder(
color: colorScheme.strokeMuted,
strokeWidth: 1,
dashPattern: const [6, 6],
radius: const Radius.circular(8),
child: Padding(
padding: const EdgeInsets.only(
left: 26.0,
top: 14,
right: 12,
bottom: 14,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
codeValue,
style: textStyle.bodyBold.copyWith(
color: colorScheme.primary700,
),
),
const SizedBox(width: 12),
Icon(
Icons.adaptive.share,
size: 22,
color: colorScheme.strokeMuted,
)
],
),
),
),
);
}
}

View file

@ -1,4 +1,3 @@
import "package:dotted_border/dotted_border.dart";
import "package:flutter/material.dart";
import "package:photos/models/api/storage_bonus/storage_bonus.dart";
import "package:photos/models/user_details.dart";
@ -14,6 +13,7 @@ import "package:photos/ui/components/menu_item_widget/menu_item_widget.dart";
import "package:photos/ui/components/title_bar_title_widget.dart";
import "package:photos/ui/components/title_bar_widget.dart";
import "package:photos/ui/growth/apply_code_screen.dart";
import "package:photos/ui/growth/referral_code_widget.dart";
import "package:photos/ui/growth/storage_details_screen.dart";
import "package:photos/utils/data_util.dart";
import "package:photos/utils/navigation_util.dart";
@ -153,41 +153,7 @@ class ReferralWidget extends StatelessWidget {
"friends",
),
const SizedBox(height: 12),
Center(
child: DottedBorder(
color: colorScheme.strokeMuted,
//color of dotted/dash line
strokeWidth: 1,
//thickness of dash/dots
dashPattern: const [6, 6],
radius: const Radius.circular(8),
child: Padding(
padding: const EdgeInsets.only(
left: 26.0,
top: 14,
right: 12,
bottom: 14,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
referralView.code,
style: textStyle.bodyBold.copyWith(
color: colorScheme.primary700,
),
),
const SizedBox(width: 12),
Icon(
Icons.adaptive.share,
size: 22,
color: colorScheme.strokeMuted,
)
],
),
),
),
),
ReferralCodeWidget(referralView.code),
const SizedBox(height: 12),
const Text(
"2. They sign up for a paid plan",