Skip to content

Commit 3db7111

Browse files
Merge pull request #1138 from cypherstack/julian
biometrics duress fix and android things
2 parents b652d38 + b51e6a8 commit 3db7111

File tree

11 files changed

+550
-561
lines changed

11 files changed

+550
-561
lines changed

lib/pages/monkey/monkey_view.dart

Lines changed: 290 additions & 321 deletions
Large diffs are not rendered by default.

lib/pages/ordinals/ordinal_details_view.dart

Lines changed: 48 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import 'package:flutter/material.dart';
55
import 'package:flutter/services.dart';
66
import 'package:flutter_riverpod/flutter_riverpod.dart';
77
import 'package:flutter_svg/flutter_svg.dart';
8+
import 'package:path/path.dart' as path;
89
import 'package:path_provider/path_provider.dart';
9-
import 'package:permission_handler/permission_handler.dart';
1010

1111
import '../../models/isar/models/blockchain_data/utxo.dart';
1212
import '../../models/isar/ordinal.dart';
@@ -21,6 +21,7 @@ import '../../utilities/amount/amount_formatter.dart';
2121
import '../../utilities/assets.dart';
2222
import '../../utilities/constants.dart';
2323
import '../../utilities/show_loading.dart';
24+
import '../../utilities/stack_file_system.dart';
2425
import '../../utilities/text_styles.dart';
2526
import '../../wallets/isar/providers/wallet_info_provider.dart';
2627
import '../../widgets/background.dart';
@@ -92,9 +93,7 @@ class _OrdinalDetailsViewState extends ConsumerState<OrdinalDetailsView> {
9293
title: "Inscription number",
9394
data: widget.ordinal.inscriptionNumber.toString(),
9495
),
95-
const SizedBox(
96-
height: _spacing,
97-
),
96+
const SizedBox(height: _spacing),
9897
_DetailsItemWCopy(
9998
title: "Inscription ID",
10099
data: widget.ordinal.inscriptionId,
@@ -103,37 +102,32 @@ class _OrdinalDetailsViewState extends ConsumerState<OrdinalDetailsView> {
103102
// height: _spacing,
104103
// ),
105104
// // todo: add utxo status
106-
const SizedBox(
107-
height: _spacing,
108-
),
105+
const SizedBox(height: _spacing),
109106
_DetailsItemWCopy(
110107
title: "Amount",
111-
data: utxo == null
112-
? "ERROR"
113-
: ref.watch(pAmountFormatter(coin)).format(
114-
Amount(
115-
rawValue: BigInt.from(utxo!.value),
116-
fractionDigits: coin.fractionDigits,
117-
),
118-
),
119-
),
120-
const SizedBox(
121-
height: _spacing,
108+
data:
109+
utxo == null
110+
? "ERROR"
111+
: ref
112+
.watch(pAmountFormatter(coin))
113+
.format(
114+
Amount(
115+
rawValue: BigInt.from(utxo!.value),
116+
fractionDigits: coin.fractionDigits,
117+
),
118+
),
122119
),
120+
const SizedBox(height: _spacing),
123121
_DetailsItemWCopy(
124122
title: "Owner address",
125123
data: utxo?.address ?? "ERROR",
126124
),
127-
const SizedBox(
128-
height: _spacing,
129-
),
125+
const SizedBox(height: _spacing),
130126
_DetailsItemWCopy(
131127
title: "Transaction ID",
132128
data: widget.ordinal.utxoTXID,
133129
),
134-
const SizedBox(
135-
height: _spacing,
136-
),
130+
const SizedBox(height: _spacing),
137131
],
138132
),
139133
),
@@ -145,11 +139,7 @@ class _OrdinalDetailsViewState extends ConsumerState<OrdinalDetailsView> {
145139
}
146140

147141
class _DetailsItemWCopy extends StatelessWidget {
148-
const _DetailsItemWCopy({
149-
super.key,
150-
required this.title,
151-
required this.data,
152-
});
142+
const _DetailsItemWCopy({super.key, required this.title, required this.data});
153143

154144
final String title;
155145
final String data;
@@ -163,10 +153,7 @@ class _DetailsItemWCopy extends StatelessWidget {
163153
Row(
164154
mainAxisAlignment: MainAxisAlignment.spaceBetween,
165155
children: [
166-
Text(
167-
title,
168-
style: STextStyles.itemSubtitle(context),
169-
),
156+
Text(title, style: STextStyles.itemSubtitle(context)),
170157
GestureDetector(
171158
onTap: () async {
172159
await Clipboard.setData(ClipboardData(text: data));
@@ -184,34 +171,29 @@ class _DetailsItemWCopy extends StatelessWidget {
184171
children: [
185172
SvgPicture.asset(
186173
Assets.svg.copy,
187-
color: Theme.of(context)
188-
.extension<StackColors>()!
189-
.infoItemIcons,
174+
color:
175+
Theme.of(
176+
context,
177+
).extension<StackColors>()!.infoItemIcons,
190178
width: 12,
191179
),
192-
const SizedBox(
193-
width: 6,
194-
),
180+
const SizedBox(width: 6),
195181
Text(
196182
"Copy",
197183
style: STextStyles.infoSmall(context).copyWith(
198-
color: Theme.of(context)
199-
.extension<StackColors>()!
200-
.infoItemIcons,
184+
color:
185+
Theme.of(
186+
context,
187+
).extension<StackColors>()!.infoItemIcons,
201188
),
202189
),
203190
],
204191
),
205192
),
206193
],
207194
),
208-
const SizedBox(
209-
height: 4,
210-
),
211-
SelectableText(
212-
data,
213-
style: STextStyles.itemSubtitle12(context),
214-
),
195+
const SizedBox(height: 4),
196+
SelectableText(data, style: STextStyles.itemSubtitle12(context)),
215197
],
216198
),
217199
);
@@ -235,9 +217,10 @@ class _OrdinalImageGroup extends ConsumerWidget {
235217

236218
final response = await client.get(
237219
url: Uri.parse(ordinal.content),
238-
proxyInfo: ref.read(prefsChangeNotifierProvider).useTor
239-
? ref.read(pTorService).getProxyInfo()
240-
: null,
220+
proxyInfo:
221+
ref.read(prefsChangeNotifierProvider).useTor
222+
? ref.read(pTorService).getProxyInfo()
223+
: null,
241224
);
242225

243226
if (response.code != 200) {
@@ -248,16 +231,14 @@ class _OrdinalImageGroup extends ConsumerWidget {
248231

249232
final bytes = response.bodyBytes;
250233

251-
if (Platform.isAndroid) {
252-
await Permission.storage.request();
253-
}
254-
255-
final dir = Platform.isAndroid
256-
? Directory("/storage/emulated/0/Documents")
257-
: await getApplicationDocumentsDirectory();
258-
259-
final docPath = dir.path;
260-
final filePath = "$docPath/ordinal_${ordinal.inscriptionNumber}.png";
234+
final dir =
235+
Platform.isAndroid
236+
? await StackFileSystem.wtfAndroidDocumentsPath()
237+
: await getApplicationDocumentsDirectory();
238+
final filePath = path.join(
239+
dir.path,
240+
"ordinal_${ordinal.inscriptionNumber}.png",
241+
);
261242

262243
final File imgFile = File(filePath);
263244

@@ -299,9 +280,7 @@ class _OrdinalImageGroup extends ConsumerWidget {
299280
),
300281
),
301282
),
302-
const SizedBox(
303-
height: _spacing,
304-
),
283+
const SizedBox(height: _spacing),
305284
Row(
306285
children: [
307286
Expanded(
@@ -311,9 +290,10 @@ class _OrdinalImageGroup extends ConsumerWidget {
311290
Assets.svg.arrowDown,
312291
width: 10,
313292
height: 12,
314-
color: Theme.of(context)
315-
.extension<StackColors>()!
316-
.buttonTextSecondary,
293+
color:
294+
Theme.of(
295+
context,
296+
).extension<StackColors>()!.buttonTextSecondary,
317297
),
318298
buttonHeight: ButtonHeight.l,
319299
iconSpacing: 4,

lib/pages/pinpad_views/lock_screen_view.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,10 @@ class _LockscreenViewState extends ConsumerState<LockscreenView> {
204204
final hasDuressPin =
205205
(await _secureStore.read(key: kDuressPinKey)) != null;
206206

207-
ref.read(pDuress.notifier).state = hasDuressPin;
207+
ref.read(pDuress.notifier).state =
208+
hasDuressPin &&
209+
ref.read(prefsChangeNotifierProvider).biometricsDuress;
210+
208211
canTryUnlock = true;
209212
} else {
210213
if (ref.read(pDuress)) {

0 commit comments

Comments
 (0)