Offline gym log for Android. No account, no ads, no internet.
Dart androidbodybuildingdartexercisesf-droidfitnessfluttergymgym-apphealthprivacyself-hostedworkoutworkout-appworkout-tracker
Set a custom barbell weight
InlitXa145fb1078b0
diff --git a/lib/screens/tool_detail_screen.dart b/lib/screens/tool_detail_screen.dartindex c863e89..f987882 100644--- a/lib/screens/tool_detail_screen.dart+++ b/lib/screens/tool_detail_screen.dart@@ -161,7 +161,7 @@ class ToolDetailScreen extends StatelessWidget {return [ToolRow(label: t.targetWeight, control: StepperControl(value: '${fit.weightValue(fit.plateTarget)} ${fit.units}', onDec: () => fit.bumpPlateTarget(-fit.fromDisplayWeight(fit.weightStep)), onInc: () => fit.bumpPlateTarget(fit.fromDisplayWeight(fit.weightStep)), onEdit: () => _editNumber(context, title: t.targetWeight, current: fit.toDisplayWeight(fit.plateTarget), decimal: true, apply: (v) => fit.bumpPlateTarget(fit.fromDisplayWeight(v) - fit.plateTarget)))),const SizedBox(height: 10),- _barWeightCard(gc),+ _barWeightCard(context, gc),const SizedBox(height: 10),_perSideCard(gc),];@@ -307,24 +307,27 @@ class ToolDetailScreen extends StatelessWidget {]);}- Widget _barWeightCard(GymColors gc) {- Widget opt(double v) {- final active = fit.plateBarDisplay == v;+ Widget _barWeightCard(BuildContext context, GymColors gc) {+ final current = fit.plateBarDisplay;+ final bars = fit.barOptions;+ final own = !bars.contains(current);+ Widget opt(String label, bool active, VoidCallback onTap) {return Expanded(child: GestureDetector(- onTap: () => fit.setPlateBar(v),+ onTap: onTap,child: Container(padding: const EdgeInsets.all(8),alignment: Alignment.center,decoration: BoxDecoration(color: active ? gc.ember : gc.bgRaised2, borderRadius: BorderRadius.circular(10)),- child: Text('${fmt(v)} ${fit.units}',+ child: Text(label,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,style: AppTheme.f(13, weight: FontWeight.w600, color: active ? gc.onEmber : gc.textSecondary)),),),);}- final bars = fit.barOptions;return SoftCard(radius: 20,borderColor: Colors.transparent,@@ -335,10 +338,12 @@ class ToolDetailScreen extends StatelessWidget {Text(t.barWeight, style: AppTheme.f(13, weight: FontWeight.w600, color: gc.textSecondary)),const SizedBox(height: 10),Row(children: [- for (int i = 0; i < bars.length; i++) ...[- if (i > 0) const SizedBox(width: 8),- opt(bars[i]),+ for (final v in bars) ...[+ opt('${fmt(v)} ${fit.units}', current == v, () => fit.setPlateBar(v)),+ const SizedBox(width: 8),],+ opt(own ? '${fmt(current)} ${fit.units}' : t.custom, own,+ () => _editNumber(context, title: t.barWeight, current: current, decimal: true, apply: fit.setPlateBar)),]),],),@@ -476,26 +481,16 @@ void showPlateSheet(BuildContext context, double displayTarget, {double? startBaconst SizedBox(height: 8),Row(children: [for (final option in fit.barOptions) ...[- if (option != fit.barOptions.first) const SizedBox(width: 8),- Expanded(- child: GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: () => setSheet(() => bar = option),- child: Container(- padding: const EdgeInsets.all(10),- alignment: Alignment.center,- decoration: BoxDecoration(- color: bar == option ? gc.ember : gc.bgRaised2,- borderRadius: BorderRadius.circular(10),- ),- child: Text('${fmt(option)} ${fit.units}',- style: AppTheme.f(13,- weight: FontWeight.w600,- color: bar == option ? gc.onEmber : gc.textSecondary)),- ),- ),- ),+ _sheetBarChip(gc, '${fmt(option)} ${fit.units}', bar == option, () => setSheet(() => bar = option)),+ const SizedBox(width: 8),],+ _sheetBarChip(+ gc,+ fit.barOptions.contains(bar) ? t.custom : '${fmt(bar)} ${fit.units}',+ !fit.barOptions.contains(bar), () async {+ final v = await askNumber(sheet, title: t.barWeight, initial: fmt(bar), decimal: true);+ if (v != null && v >= 0) setSheet(() => bar = v);+ }),]),const SizedBox(height: 18),Text(t.perSide,@@ -530,3 +525,22 @@ void showPlateSheet(BuildContext context, double displayTarget, {double? startBa),);}++Widget _sheetBarChip(GymColors gc, String label, bool active, VoidCallback onTap) => Expanded(+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: onTap,+ child: Container(+ padding: const EdgeInsets.all(10),+ alignment: Alignment.center,+ decoration: BoxDecoration(+ color: active ? gc.ember : gc.bgRaised2,+ borderRadius: BorderRadius.circular(10),+ ),+ child: Text(label,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: AppTheme.f(13, weight: FontWeight.w600, color: active ? gc.onEmber : gc.textSecondary)),+ ),+ ),+ );diff --git a/lib/state/tools_state.dart b/lib/state/tools_state.dartindex 22b9542..89c5dd7 100644--- a/lib/state/tools_state.dart+++ b/lib/state/tools_state.dart@@ -18,7 +18,7 @@ mixin ToolsState on FitCore {double bfWaist = 84;double bfHip = 95;double plateTarget = 100;- double plateBar = 20;+ double? plateBar;double warmupTarget = 100;double rpeWeight = 100;int rpeReps = 5;@@ -132,11 +132,13 @@ mixin ToolsState on FitCore {isLb ? const [45, 35, 25, 10, 5, 2.5] : const [25, 20, 15, 10, 5, 2.5, 1.25];List<({double weight, int count})> get plateBreakdown =>- platesPerSide(toDisplayWeight(plateTarget), toDisplayWeight(plateBar));+ platesPerSide(toDisplayWeight(plateTarget), plateBarDisplay);double get defaultBar {final placeBar = placeBarKg;if (placeBar != null) return _round1(toDisplayWeight(placeBar));+ final own = plateBar;+ if (own != null) return _round1(toDisplayWeight(own));return isLb ? 45 : 20;}@@ -261,9 +263,16 @@ mixin ToolsState on FitCore {void bumpPlateTarget(double d) { plateTarget = _clamp(plateTarget + d, 0, null); notifyListeners(); }- void setPlateBar(double b) { plateBar = fromDisplayWeight(b); notifyListeners(); }+ void setPlateBar(double b) {+ plateBar = fromDisplayWeight(b.clamp(0, isLb ? 220 : 100).toDouble());+ _persist();+ notifyListeners();+ }- double get plateBarDisplay => _round1(toDisplayWeight(plateBar));+ double get plateBarDisplay {+ final own = plateBar;+ return own == null ? (isLb ? 45 : 20) : _round1(toDisplayWeight(own));+ }static double _effortShare(int reps, double rpe) => rpePercent(reps, rpe) ?? 1 / (1 + reps / 30);