mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-19 05:58:50 +02:00
Cw 586 display user twitter image in birdpay (#1315)
* Update address_validator.dart * add twitter profile image * mastodon profile image * fix data types
This commit is contained in:
@@ -11,6 +11,8 @@ Future<String> extractAddressFromParsed(
|
||||
var title = '';
|
||||
var content = '';
|
||||
var address = '';
|
||||
var profileImageUrl = '';
|
||||
var profileName = '';
|
||||
|
||||
switch (parsedAddress.parseFrom) {
|
||||
case ParseFrom.unstoppableDomains:
|
||||
@@ -37,11 +39,15 @@ Future<String> extractAddressFromParsed(
|
||||
title = S.of(context).address_detected;
|
||||
content = S.of(context).extracted_address_content('${parsedAddress.name} (Twitter)');
|
||||
address = parsedAddress.addresses.first;
|
||||
profileImageUrl = parsedAddress.profileImageUrl;
|
||||
profileName = parsedAddress.profileName;
|
||||
break;
|
||||
case ParseFrom.mastodon:
|
||||
title = S.of(context).address_detected;
|
||||
content = S.of(context).extracted_address_content('${parsedAddress.name} (Mastodon)');
|
||||
address = parsedAddress.addresses.first;
|
||||
profileImageUrl = parsedAddress.profileImageUrl;
|
||||
profileName = parsedAddress.profileName;
|
||||
break;
|
||||
case ParseFrom.nostr:
|
||||
title = S.of(context).address_detected;
|
||||
@@ -95,6 +101,8 @@ Future<String> extractAddressFromParsed(
|
||||
|
||||
return AlertWithOneAction(
|
||||
alertTitle: title,
|
||||
headerTitleText: profileName.isEmpty ? null : profileName,
|
||||
headerImageProfileUrl: profileImageUrl.isEmpty ? null : profileImageUrl,
|
||||
alertContent: content,
|
||||
buttonText: S.of(context).ok,
|
||||
buttonAction: () => Navigator.of(context).pop());
|
||||
|
||||
@@ -7,7 +7,9 @@ class AlertWithOneAction extends BaseAlertDialog {
|
||||
required this.alertContent,
|
||||
required this.buttonText,
|
||||
required this.buttonAction,
|
||||
this.alertBarrierDismissible = true
|
||||
this.alertBarrierDismissible = true,
|
||||
this.headerTitleText,
|
||||
this.headerImageProfileUrl
|
||||
});
|
||||
|
||||
final String alertTitle;
|
||||
@@ -15,6 +17,8 @@ class AlertWithOneAction extends BaseAlertDialog {
|
||||
final String buttonText;
|
||||
final VoidCallback buttonAction;
|
||||
final bool alertBarrierDismissible;
|
||||
final String? headerTitleText;
|
||||
final String? headerImageProfileUrl;
|
||||
|
||||
@override
|
||||
String get titleText => alertTitle;
|
||||
@@ -25,6 +29,12 @@ class AlertWithOneAction extends BaseAlertDialog {
|
||||
@override
|
||||
bool get barrierDismissible => alertBarrierDismissible;
|
||||
|
||||
@override
|
||||
String? get headerImageUrl => headerImageProfileUrl;
|
||||
|
||||
@override
|
||||
String? get headerText => headerTitleText;
|
||||
|
||||
@override
|
||||
Widget actionButtons(BuildContext context) {
|
||||
return Container(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:cake_wallet/src/screens/receive/widgets/header_tile.dart';
|
||||
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
|
||||
import 'dart:ui';
|
||||
import 'package:cake_wallet/src/widgets/section_divider.dart';
|
||||
@@ -5,19 +6,34 @@ import 'package:cake_wallet/themes/extensions/alert_theme.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BaseAlertDialog extends StatelessWidget {
|
||||
String? get headerText => '';
|
||||
|
||||
String get titleText => '';
|
||||
|
||||
String get contentText => '';
|
||||
|
||||
String get leftActionButtonText => '';
|
||||
|
||||
String get rightActionButtonText => '';
|
||||
|
||||
bool get isDividerExists => false;
|
||||
|
||||
VoidCallback get actionLeft => () {};
|
||||
|
||||
VoidCallback get actionRight => () {};
|
||||
|
||||
bool get barrierDismissible => true;
|
||||
|
||||
Color? get leftActionButtonTextColor => null;
|
||||
|
||||
Color? get rightActionButtonTextColor => null;
|
||||
|
||||
Color? get leftActionButtonColor => null;
|
||||
|
||||
Color? get rightActionButtonColor => null;
|
||||
|
||||
String? get headerImageUrl => null;
|
||||
|
||||
Widget title(BuildContext context) {
|
||||
return Text(
|
||||
titleText,
|
||||
@@ -32,6 +48,23 @@ class BaseAlertDialog extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget headerTitle(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 10.0),
|
||||
child: Text(
|
||||
headerText!,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontFamily: 'Lato',
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget content(BuildContext context) {
|
||||
return Text(
|
||||
contentText,
|
||||
@@ -48,17 +81,17 @@ class BaseAlertDialog extends StatelessWidget {
|
||||
|
||||
Widget actionButtons(BuildContext context) {
|
||||
return Container(
|
||||
height: 60,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
height: 60,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: TextButton(
|
||||
onPressed: actionLeft,
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: leftActionButtonColor ??
|
||||
Theme.of(context).dialogBackgroundColor,
|
||||
backgroundColor:
|
||||
leftActionButtonColor ?? Theme.of(context).dialogBackgroundColor,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.zero))),
|
||||
child: Text(
|
||||
@@ -79,8 +112,8 @@ class BaseAlertDialog extends StatelessWidget {
|
||||
child: TextButton(
|
||||
onPressed: actionRight,
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: rightActionButtonColor ??
|
||||
Theme.of(context).dialogBackgroundColor,
|
||||
backgroundColor:
|
||||
rightActionButtonColor ?? Theme.of(context).dialogBackgroundColor,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.zero))),
|
||||
child: Text(
|
||||
@@ -90,8 +123,7 @@ class BaseAlertDialog extends StatelessWidget {
|
||||
fontSize: 15,
|
||||
fontFamily: 'Lato',
|
||||
fontWeight: FontWeight.w600,
|
||||
color: rightActionButtonTextColor ??
|
||||
Theme.of(context).primaryColor,
|
||||
color: rightActionButtonTextColor ?? Theme.of(context).primaryColor,
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
)),
|
||||
@@ -100,6 +132,24 @@ class BaseAlertDialog extends StatelessWidget {
|
||||
));
|
||||
}
|
||||
|
||||
Widget headerImage(BuildContext context, String imageUrl) {
|
||||
return Positioned(
|
||||
top: -50,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: CircleAvatar(
|
||||
radius: 50,
|
||||
backgroundColor: Colors.white,
|
||||
child: ClipOval(
|
||||
child: Image.network(
|
||||
imageUrl,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
@@ -109,43 +159,51 @@ class BaseAlertDialog extends StatelessWidget {
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 3.0, sigmaY: 3.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
Theme.of(context).extension<AlertTheme>()!.backdropColor),
|
||||
decoration:
|
||||
BoxDecoration(color: Theme.of(context).extension<AlertTheme>()!.backdropColor),
|
||||
child: Center(
|
||||
child: GestureDetector(
|
||||
onTap: () => null,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.all(Radius.circular(30)),
|
||||
child: Container(
|
||||
width: 300,
|
||||
color: Theme.of(context).dialogBackgroundColor,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(24, 20, 24, 0),
|
||||
child: title(context),
|
||||
),
|
||||
isDividerExists
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(top: 16, bottom: 8),
|
||||
child: const HorizontalSectionDivider(),
|
||||
)
|
||||
: Offstage(),
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(24, 8, 24, 32),
|
||||
child: content(context),
|
||||
)
|
||||
],
|
||||
),
|
||||
const HorizontalSectionDivider(),
|
||||
actionButtons(context)
|
||||
],
|
||||
),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
color: Theme.of(context).dialogBackgroundColor),
|
||||
width: 300,
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
if (headerImageUrl != null) headerImage(context, headerImageUrl!),
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
if (headerImageUrl != null) const SizedBox(height: 50),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
if (headerText != null) headerTitle(context),
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(24, 20, 24, 0),
|
||||
child: title(context),
|
||||
),
|
||||
isDividerExists
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(top: 16, bottom: 8),
|
||||
child: const HorizontalSectionDivider(),
|
||||
)
|
||||
: Offstage(),
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(24, 8, 24, 32),
|
||||
child: content(context),
|
||||
)
|
||||
],
|
||||
),
|
||||
const HorizontalSectionDivider(),
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.all(Radius.circular(30)),
|
||||
child: actionButtons(context))
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user