mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-11-14 09:14:05 +01:00
* charts (wip) * charts (wip) * wip * add asset grid * split files * logic wip * proper getPrices logic * viewmodel (wip) * charts * remove unused import * remove restricted import...? * fix background gradient when scrolling * add safeguards for broken db * save new pin on removal * add safeguards for concurrency * add haptic feedback * fix haptic feedback * fix fiat ticker * reduce chart padding * add line touch indicator * improve touch target size on range selector * add date/time display when viewing past amount * merge * remove iconSvgPath reference * merge * fix state for date display * merge * auto-reformat * only load charts when page is opened * merge * reformat and apply lints * refactor to use `Money` instead of storing amount in `String` * add slop comment * fix exception on division by zero * ci * workaround toDouble being removed * disable strict parsing and rounding * fix abs() * use new currency picker sheet * safeguard for max flutter-supported decimals * fix amount precision * adjust to new buy/sell * Update lib/new-ui/pages/charts_page.dart Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * adjust buy/sell di * replace -> ignore * reformat --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
73 lines
2.5 KiB
Dart
73 lines
2.5 KiB
Dart
import "package:cake_wallet/new-ui/model/charts/util/chart_range.dart";
|
|
import "package:flutter/material.dart";
|
|
|
|
class ChartRangeSelector extends StatelessWidget {
|
|
const ChartRangeSelector({required this.selectedRange, required this.onRangeSelected, super.key});
|
|
|
|
final ChartRange selectedRange;
|
|
final Function(ChartRange) onRangeSelected;
|
|
|
|
static const double optionSize = 36;
|
|
static const double optionPadding = 24;
|
|
static const Duration switchDuration = Duration(milliseconds: 250);
|
|
|
|
double pillPosition(int selectedIndex) => selectedIndex * (optionSize + optionPadding);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final selectedIndex = ChartRange.ranges.indexOf(selectedRange);
|
|
|
|
return Stack(
|
|
children: [
|
|
AnimatedPositioned(
|
|
curve: Curves.easeOutCubic,
|
|
left: pillPosition(selectedIndex),
|
|
duration: switchDuration,
|
|
child: Container(
|
|
height: optionSize,
|
|
width: optionSize,
|
|
decoration: BoxDecoration(
|
|
color: Theme.of(context).colorScheme.onSurface.withAlpha(25),
|
|
borderRadius: BorderRadius.circular(999999),
|
|
),
|
|
),
|
|
),
|
|
Row(
|
|
children: ChartRange.ranges.map((item) {
|
|
final selected = selectedRange == item;
|
|
final isFirst = ChartRange.ranges.indexOf(item) == 0;
|
|
return GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () {
|
|
if (!selected) {
|
|
onRangeSelected(item);
|
|
}
|
|
},
|
|
child: Padding(
|
|
padding: EdgeInsets.only(
|
|
right: optionPadding / 2,
|
|
left: isFirst ? 0 : optionPadding / 2,
|
|
),
|
|
child: SizedBox(
|
|
width: optionSize,
|
|
height: optionSize,
|
|
child: AnimatedDefaultTextStyle(
|
|
duration: switchDuration,
|
|
style: TextStyle(
|
|
fontWeight: selected ? FontWeight.w400 : FontWeight.w500,
|
|
color: selected
|
|
? Theme.of(context).colorScheme.onSurface
|
|
: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
),
|
|
child: Center(child: Text(item.displayText)),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}).toList(),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|