Skip to content

Commit 8a0f78e

Browse files
committed
basic message signing
1 parent 30730b8 commit 8a0f78e

16 files changed

Lines changed: 1360 additions & 204 deletions

File tree

lib/pages/receive_view/addresses/address_card.dart

Lines changed: 132 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ class AddressCard extends ConsumerStatefulWidget {
5050
required this.coin,
5151
this.onPressed,
5252
this.clipboard = const ClipboardWrapper(),
53+
this.compact = false,
5354
});
5455

5556
final int addressId;
5657
final String walletId;
5758
final CryptoCurrency coin;
5859
final ClipboardInterface clipboard;
5960
final VoidCallback? onPressed;
61+
final bool compact;
6062

6163
@override
6264
ConsumerState<AddressCard> createState() => _AddressCardState();
@@ -142,11 +144,10 @@ class _AddressCardState extends ConsumerState<AddressCard> {
142144

143145
@override
144146
void initState() {
145-
address =
146-
MainDB.instance.isar.addresses
147-
.where()
148-
.idEqualTo(widget.addressId)
149-
.findFirstSync()!;
147+
address = MainDB.instance.isar.addresses
148+
.where()
149+
.idEqualTo(widget.addressId)
150+
.findFirstSync()!;
150151

151152
label = MainDB.instance.getAddressLabelSync(widget.walletId, address.value);
152153
Id? id = label?.id;
@@ -155,12 +156,11 @@ class _AddressCardState extends ConsumerState<AddressCard> {
155156
walletId: widget.walletId,
156157
addressString: address.value,
157158
value: "",
158-
tags:
159-
address.subType == AddressSubType.receiving
160-
? ["receiving"]
161-
: address.subType == AddressSubType.change
162-
? ["change"]
163-
: null,
159+
tags: address.subType == AddressSubType.receiving
160+
? ["receiving"]
161+
: address.subType == AddressSubType.change
162+
? ["change"]
163+
: null,
164164
);
165165
id = MainDB.instance.putAddressLabelSync(label!);
166166
}
@@ -181,20 +181,19 @@ class _AddressCardState extends ConsumerState<AddressCard> {
181181
}
182182

183183
return ConditionalParent(
184-
condition: isDesktop,
185-
builder:
186-
(child) => Row(
187-
crossAxisAlignment: CrossAxisAlignment.start,
188-
children: [
189-
SvgPicture.file(
190-
File(ref.watch(coinIconProvider(widget.coin))),
191-
width: 32,
192-
height: 32,
193-
),
194-
const SizedBox(width: 12),
195-
Expanded(child: child),
196-
],
184+
condition: isDesktop && !widget.compact,
185+
builder: (child) => Row(
186+
crossAxisAlignment: CrossAxisAlignment.start,
187+
children: [
188+
SvgPicture.file(
189+
File(ref.watch(coinIconProvider(widget.coin))),
190+
width: 32,
191+
height: 32,
197192
),
193+
const SizedBox(width: 12),
194+
Expanded(child: child),
195+
],
196+
),
198197
child: Column(
199198
crossAxisAlignment: CrossAxisAlignment.start,
200199
children: [
@@ -230,129 +229,124 @@ class _AddressCardState extends ConsumerState<AddressCard> {
230229
),
231230
],
232231
),
233-
const SizedBox(height: 10),
234-
Row(
235-
children: [
236-
CustomTextButton(
237-
text: "Copy address",
238-
onTap: () {
239-
widget.clipboard
240-
.setData(ClipboardData(text: address.value))
241-
.then((value) {
242-
if (context.mounted) {
243-
unawaited(
244-
showFloatingFlushBar(
245-
type: FlushBarType.info,
246-
message: "Copied to clipboard",
247-
context: context,
248-
),
249-
);
250-
}
251-
});
252-
},
253-
),
254-
const SizedBox(width: 16),
255-
CustomTextButton(
256-
text: "Show QR code",
257-
onTap: () async {
258-
await showDialog<void>(
259-
context: context,
260-
builder: (_) {
261-
return StackDialogBase(
262-
child: Column(
263-
children: [
264-
if (label!.value.isNotEmpty)
265-
Text(
266-
label!.value,
267-
style: STextStyles.w600_18(context),
232+
if (!widget.compact) const SizedBox(height: 10),
233+
if (!widget.compact)
234+
Row(
235+
children: [
236+
CustomTextButton(
237+
text: "Copy address",
238+
onTap: () {
239+
widget.clipboard
240+
.setData(ClipboardData(text: address.value))
241+
.then((value) {
242+
if (context.mounted) {
243+
unawaited(
244+
showFloatingFlushBar(
245+
type: FlushBarType.info,
246+
message: "Copied to clipboard",
247+
context: context,
268248
),
269-
if (label!.value.isNotEmpty)
270-
const SizedBox(height: 8),
271-
Text(
272-
address.value,
273-
style: STextStyles.w500_16(
274-
context,
275-
).copyWith(
276-
color:
277-
Theme.of(context)
278-
.extension<StackColors>()!
279-
.textSubtitle1,
249+
);
250+
}
251+
});
252+
},
253+
),
254+
const SizedBox(width: 16),
255+
CustomTextButton(
256+
text: "Show QR code",
257+
onTap: () async {
258+
await showDialog<void>(
259+
context: context,
260+
builder: (_) {
261+
return StackDialogBase(
262+
child: Column(
263+
children: [
264+
if (label!.value.isNotEmpty)
265+
Text(
266+
label!.value,
267+
style: STextStyles.w600_18(context),
268+
),
269+
if (label!.value.isNotEmpty)
270+
const SizedBox(height: 8),
271+
Text(
272+
address.value,
273+
style: STextStyles.w500_16(context)
274+
.copyWith(
275+
color: Theme.of(context)
276+
.extension<StackColors>()!
277+
.textSubtitle1,
278+
),
280279
),
281-
),
282-
const SizedBox(height: 16),
283-
Center(
284-
child: RepaintBoundary(
285-
key: _qrKey,
286-
child: QR(
287-
data: AddressUtils.buildUriString(
288-
widget.coin.uriScheme,
289-
address.value,
290-
{},
280+
const SizedBox(height: 16),
281+
Center(
282+
child: RepaintBoundary(
283+
key: _qrKey,
284+
child: QR(
285+
data: AddressUtils.buildUriString(
286+
widget.coin.uriScheme,
287+
address.value,
288+
{},
289+
),
290+
size: 220,
291291
),
292-
size: 220,
293292
),
294293
),
295-
),
296-
const SizedBox(height: 16),
297-
Row(
298-
children: [
299-
if (!isDesktop)
300-
Expanded(
301-
child: SecondaryButton(
302-
label: "Share",
303-
buttonHeight:
304-
isDesktop
305-
? ButtonHeight.l
306-
: null,
307-
icon: SvgPicture.asset(
308-
Assets.svg.share,
309-
width: 14,
310-
height: 14,
311-
color:
312-
Theme.of(context)
313-
.extension<StackColors>()!
314-
.buttonTextSecondary,
294+
const SizedBox(height: 16),
295+
Row(
296+
children: [
297+
if (!isDesktop)
298+
Expanded(
299+
child: SecondaryButton(
300+
label: "Share",
301+
buttonHeight: isDesktop
302+
? ButtonHeight.l
303+
: null,
304+
icon: SvgPicture.asset(
305+
Assets.svg.share,
306+
width: 14,
307+
height: 14,
308+
color: Theme.of(context)
309+
.extension<StackColors>()!
310+
.buttonTextSecondary,
311+
),
312+
onPressed: () async {
313+
await _capturePng(false);
314+
},
315315
),
316-
onPressed: () async {
317-
await _capturePng(false);
318-
},
319316
),
320-
),
321-
if (isDesktop)
322-
Expanded(
323-
child: PrimaryButton(
324-
buttonHeight:
325-
isDesktop
326-
? ButtonHeight.l
327-
: null,
328-
onPressed: () async {
329-
// TODO: add save functionality instead of share
330-
// save works on linux at the moment
331-
await _capturePng(true);
332-
},
333-
label: "Save",
334-
icon: SvgPicture.asset(
335-
Assets.svg.arrowDown,
336-
width: 20,
337-
height: 20,
338-
color:
339-
Theme.of(context)
340-
.extension<StackColors>()!
341-
.buttonTextPrimary,
317+
if (isDesktop)
318+
Expanded(
319+
child: PrimaryButton(
320+
buttonHeight: isDesktop
321+
? ButtonHeight.l
322+
: null,
323+
onPressed: () async {
324+
// TODO: add save functionality instead of share
325+
// save works on linux at the moment
326+
await _capturePng(true);
327+
},
328+
label: "Save",
329+
icon: SvgPicture.asset(
330+
Assets.svg.arrowDown,
331+
width: 20,
332+
height: 20,
333+
color: Theme.of(context)
334+
.extension<StackColors>()!
335+
.buttonTextPrimary,
336+
),
342337
),
343338
),
344-
),
345-
],
346-
),
347-
],
348-
),
349-
);
350-
},
351-
);
352-
},
353-
),
354-
],
355-
),
339+
],
340+
),
341+
],
342+
),
343+
);
344+
},
345+
);
346+
},
347+
),
348+
],
349+
),
356350
// if (label!.tags != null && label!.tags!.isNotEmpty)
357351
// Wrap(
358352
// spacing: 10,

0 commit comments

Comments
 (0)