Skip to content

Commit

Permalink
import fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mocodesmo committed Jun 26, 2023
1 parent 80ae7b5 commit 9be5d83
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 86 deletions.
13 changes: 13 additions & 0 deletions lib/_ui/toast.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:bb_mobile/_ui/components/text.dart';
import 'package:bb_mobile/styles.dart';
import 'package:flutter/material.dart';

extension Xontext on BuildContext {
SnackBar showToast(String text) {
final bgColor = colour.onBackground;
return SnackBar(
content: Center(child: BBText.titleLarge(text, onSurface: true)),
backgroundColor: bgColor,
);
}
}
5 changes: 2 additions & 3 deletions lib/auth/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:bb_mobile/_pkg/storage.dart';
import 'package:bb_mobile/_ui/app_bar.dart';
import 'package:bb_mobile/_ui/components/button.dart';
import 'package:bb_mobile/_ui/components/text.dart';
import 'package:bb_mobile/_ui/toast.dart';
import 'package:bb_mobile/auth/bloc/cubit.dart';
import 'package:bb_mobile/auth/bloc/state.dart';
import 'package:bb_mobile/home/bloc/home_cubit.dart';
Expand Down Expand Up @@ -39,9 +40,7 @@ class AuthPage extends StatelessWidget {
context.go('/home');
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: BBText.body('Pin Changed'),
),
context.showToast('Pin Changed'),
);
context.pop();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/import/bloc/import_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class ImportWalletCubit extends Cubit<ImportState> {
);
emit(state.copyWith(errSavingWallet: ''));

nfc.stopSession();
stopScanningNFC();

default:
break;
Expand Down
175 changes: 101 additions & 74 deletions lib/import/wallet_type_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,92 +209,119 @@ class _ImportWalletTypeButton extends StatelessWidget {
Row(
children: [
Expanded(
child: Container(
margin: const EdgeInsets.only(right: 40),
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(32.0)),
border: Border.all(
width: selected ? 4 : 1,
color: selected ? context.colour.primary : context.colour.onBackground,
),
),
child: Padding(
padding: const EdgeInsets.only(right: 40),
child: InkWell(
onTap: () {
context.read<ImportWalletCubit>().walletTypeChanged(walletType);
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
children: [
BBText.body(
name,
),
const Spacer(),
SizedBox(
width: 16,
height: 16,
child: syncing
? CircularProgressIndicator(
color: context.colour.primary,
strokeWidth: 2,
)
: const SizedBox.shrink(),
),
],
radius: 32,
child: Container(
constraints: const BoxConstraints(minHeight: 100),
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(32.0)),
border: Border.all(
width: selected ? 4 : 1,
color: selected ? context.colour.primary : context.colour.onBackground,
),
const Gap(4),
if (address.isNotEmpty)
BBText.body(
address,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
children: [
BBText.body(
name,
),
const Spacer(),
SizedBox(
width: 16,
height: 16,
child: syncing
? CircularProgressIndicator(
color: context.colour.primary,
strokeWidth: 2,
)
: const SizedBox.shrink(),
),
],
),
const Gap(4),
if (fingerprint.isNotEmpty)
RichText(
text: TextSpan(
children: [
TextSpan(
text: 'Wallet fingerprint (XFP): ',
style: TextStyle(
fontSize: 12,
color: context.colour.onBackground,
const Gap(4),
if (syncing) ...[
const BBText.bodySmall(
'Scanning wallet ...',
),
],
if (address.isNotEmpty)
RichText(
text: TextSpan(
children: [
TextSpan(
text: 'First Address: ',
style: TextStyle(
fontSize: 12,
color: context.colour.onBackground,
),
),
),
TextSpan(
text: fingerprint,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: context.colour.onBackground,
TextSpan(
text: address,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: context.colour.onBackground,
),
),
),
],
],
),
),
),
if (balance != null)
RichText(
text: TextSpan(
children: [
TextSpan(
text: 'Balance: ',
style: TextStyle(
fontSize: 12,
color: context.colour.onBackground,
const Gap(4),
if (fingerprint.isNotEmpty)
RichText(
text: TextSpan(
children: [
TextSpan(
text: 'Wallet fingerprint (XFP): ',
style: TextStyle(
fontSize: 12,
color: context.colour.onBackground,
),
),
),
TextSpan(
text: balance.total.toString(),
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: context.colour.onBackground,
TextSpan(
text: fingerprint,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: context.colour.onBackground,
),
),
),
],
],
),
),
),
],
if (balance != null)
RichText(
text: TextSpan(
children: [
TextSpan(
text: 'Balance: ',
style: TextStyle(
fontSize: 12,
color: context.colour.onBackground,
),
),
TextSpan(
text: balance.total.toString(),
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: context.colour.onBackground,
),
),
],
),
),
],
),
),
),
),
Expand Down
23 changes: 18 additions & 5 deletions lib/import/xpub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:bb_mobile/_ui/components/text.dart';
import 'package:bb_mobile/_ui/components/text_input.dart';
import 'package:bb_mobile/_ui/popup_border.dart';
import 'package:bb_mobile/_ui/templates/headers.dart';
import 'package:bb_mobile/_ui/toast.dart';
import 'package:bb_mobile/import/bloc/import_cubit.dart';
import 'package:bb_mobile/import/bloc/import_state.dart';
import 'package:bb_mobile/styles.dart';
Expand Down Expand Up @@ -172,7 +173,12 @@ class _ImportButtons extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
BBButton.text(label: 'Hardware wallet instruction', onPressed: () {}),
BBButton.text(
label: 'Hardware wallet instruction',
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(context.showToast('Coming soon'));
},
),
BBButton.text(
label: 'Advanced Options',
onPressed: () {
Expand Down Expand Up @@ -320,7 +326,7 @@ class ImportScanning extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (isColdCard) ...[
const ColdCardLogo(),
const ColdCardLogo(isLeft: false),
// const BBText.title(
// 'ColdCard',
// isRed: true,
Expand All @@ -329,7 +335,7 @@ class ImportScanning extends StatelessWidget {
const Gap(16),
],
const BBText.title(
'Scanning for wallets',
"Please scan via device's NFC",
isRed: true,
),
const Gap(16),
Expand All @@ -340,11 +346,18 @@ class ImportScanning extends StatelessWidget {
}

class ColdCardLogo extends StatelessWidget {
const ColdCardLogo({super.key});
const ColdCardLogo({super.key, this.isLeft = true});

final bool isLeft;

@override
Widget build(BuildContext context) {
return CenterLeft(
if (isLeft) {
return CenterLeft(
child: Image.asset('assets/cc-logo.png'),
);
}
return Center(
child: Image.asset('assets/cc-logo.png'),
);
}
Expand Down
5 changes: 2 additions & 3 deletions lib/receive/receive_popup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:bb_mobile/_ui/components/button.dart';
import 'package:bb_mobile/_ui/components/text.dart';
import 'package:bb_mobile/_ui/components/text_input.dart';
import 'package:bb_mobile/_ui/popup_border.dart';
import 'package:bb_mobile/_ui/toast.dart';
import 'package:bb_mobile/home/bloc/home_cubit.dart';
import 'package:bb_mobile/locator.dart';
import 'package:bb_mobile/receive/bloc/receive_cubit.dart';
Expand Down Expand Up @@ -200,9 +201,7 @@ class InvoiceAddress extends StatelessWidget {
SystemSound.play(SystemSoundType.click);
HapticFeedback.selectionClick();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: BBText.body('Copied'),
),
context.showToast('Copied'),
);
},
iconSize: 16,
Expand Down

0 comments on commit 9be5d83

Please sign in to comment.