Skip to content

Commit

Permalink
UI: Keep scroll position when switching tabs
Browse files Browse the repository at this point in the history
Only change visibility rather than the precense of each tab's contents,
so that its internal state, like scroll position, isn't lost.
  • Loading branch information
bjorn committed Sep 15, 2023
1 parent bd1a2b2 commit 45abce1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
28 changes: 19 additions & 9 deletions cryptotax_ui/ui/appwindow.slint
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,27 @@ export component AppWindow inherits Window {
}
}

if (active-page == Page.sources): Sources {
sources: root.sources;
}
Rectangle {
Sources {
visible: active-page == Page.sources;
sources: root.sources;
}

if (active-page == Page.transactions): Transactions {
transactions: root.transactions;
open-transaction(s) => { root.open-transaction(s); }
}
Transactions {
visible: active-page == Page.transactions;
transactions: root.transactions;
open-transaction(s) => { root.open-transaction(s); }
}

CapitalGains {
visible: active-page == Page.capital-gains;
gain-entries: root.gain-entries;

if (active-page == Page.capital-gains): CapitalGains {
gain-entries: root.gain-entries;
// somehow a StandardTableView doesn't do this by default
// also, Slint compiler crashes if I put this in the component?
width: 100%;
height: 100%;
}
}
}
}
3 changes: 0 additions & 3 deletions cryptotax_ui/ui/capital-gains.slint
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import { StandardTableView } from "std-widgets.slint";
export component CapitalGains inherits StandardTableView {
in property <[[StandardListViewItem]]> gain-entries;

width: 100%;
height: 100%;

columns: [
{ title: "Currency" },
{ title: "Bought" },
Expand Down

0 comments on commit 45abce1

Please sign in to comment.