From 8c897ca1a86b849e637a31c3af6189545fc615bd Mon Sep 17 00:00:00 2001 From: Hanh Date: Sat, 14 Aug 2021 16:02:30 +0800 Subject: [PATCH] Exclude notes in flight --- android/app/build.gradle | 4 ++-- lib/account.dart | 13 ++++++++----- lib/store.dart | 10 ++++++---- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 3fe5db7..cccb3e2 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -27,8 +27,8 @@ if (flutterVersionName == null) { flutterVersionName = '1.0' } -//def appTitle = System.getenv('APP_TITLE') -def appTitle = "YWallet" +def appTitle = System.getenv('APP_TITLE') +//def appTitle = "YWallet" apply plugin: 'com.android.application' apply plugin: 'kotlin-android' diff --git a/lib/account.dart b/lib/account.dart index 8cde9fc..e1c7013 100644 --- a/lib/account.dart +++ b/lib/account.dart @@ -572,6 +572,11 @@ class NotesDataSource extends DataTableSource { final confsOrHeight = settings.showConfirmations ? syncStatus.latestHeight - note.height + 1 : note.height; + + var style = _confirmed(note.height) ? theme.textTheme.bodyText2 : theme.textTheme.overline; + if (note.spent) + style = style.merge(TextStyle(decoration: TextDecoration.lineThrough)); + return DataRow.byIndex( index: index, selected: note.excluded, @@ -581,11 +586,9 @@ class NotesDataSource extends DataTableSource { : theme.backgroundColor), cells: [ DataCell(Text("$confsOrHeight", - style: !_confirmed(note.height) - ? Theme.of(this.context).textTheme.overline - : null)), - DataCell(Text("${note.timestamp}")), - DataCell(Text("${note.value.toStringAsFixed(8)}")), + style: style)), + DataCell(Text("${note.timestamp}", style: style)), + DataCell(Text("${note.value.toStringAsFixed(8)}", style: style)), ], onSelectChanged: (selected) => _noteSelected(note, selected), ); diff --git a/lib/store.dart b/lib/store.dart index 02f542b..7594a40 100644 --- a/lib/store.dart +++ b/lib/store.dart @@ -332,7 +332,7 @@ abstract class _AccountManager with Store { Future getBalanceSpendable(int height) async { final List res = await db.rawQuery( - "SELECT SUM(value) AS value FROM received_notes WHERE account = ?1 AND (spent IS NULL OR spent = 0) " + "SELECT SUM(value) AS value FROM received_notes WHERE account = ?1 AND spent IS NULL " "AND height <= ?2 AND (excluded IS NULL OR NOT excluded)", [active.id, height]); if (res.isEmpty) return 0; @@ -417,7 +417,7 @@ abstract class _AccountManager with Store { Future _fetchNotesAndHistory(int accountId) async { await _updateBalance(accountId); final List res = await db.rawQuery( - "SELECT n.id_note, n.height, n.value, t.timestamp, n.excluded FROM received_notes n, transactions t " + "SELECT n.id_note, n.height, n.value, t.timestamp, n.excluded, n.spent FROM received_notes n, transactions t " "WHERE n.account = ?1 AND (n.spent IS NULL OR n.spent = 0) " "AND n.tx = t.id_tx", [accountId]); @@ -427,7 +427,8 @@ abstract class _AccountManager with Store { final timestamp = noteDateFormat .format(DateTime.fromMillisecondsSinceEpoch(row['timestamp'] * 1000)); final excluded = (row['excluded'] ?? 0) != 0; - return Note(id, height, timestamp, row['value'] / ZECUNIT, excluded); + final spent = row['spent'] == 0; + return Note(id, height, timestamp, row['value'] / ZECUNIT, excluded, spent); }).toList(); _sortNoteAmount(noteSortOrder); @@ -682,8 +683,9 @@ class Note { String timestamp; double value; bool excluded; + bool spent; - Note(this.id, this.height, this.timestamp, this.value, this.excluded); + Note(this.id, this.height, this.timestamp, this.value, this.excluded, this.spent); } class Tx {