mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-25 00:40:39 +00:00
added autosize text
This commit is contained in:
parent
006158c731
commit
778ab12de0
2 changed files with 52 additions and 15 deletions
|
@ -1,3 +1,4 @@
|
|||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lightmeter/res/dimens.dart';
|
||||
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||
|
@ -15,22 +16,9 @@ class ExposurePairsListItem<T extends PhotographyStopValue> extends StatelessWid
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<Widget> rowChildren = [
|
||||
Flexible(
|
||||
child: Text(
|
||||
value.toString(),
|
||||
style: labelTextStyle(context).copyWith(color: Theme.of(context).colorScheme.onBackground),
|
||||
softWrap: false,
|
||||
overflow: TextOverflow.fade,
|
||||
),
|
||||
),
|
||||
_Title(value),
|
||||
const SizedBox(width: Dimens.grid8),
|
||||
ColoredBox(
|
||||
color: Theme.of(context).colorScheme.onBackground,
|
||||
child: SizedBox(
|
||||
height: 1,
|
||||
width: tickLength(),
|
||||
),
|
||||
),
|
||||
if (value.stopType == StopType.full) const _Tick.full() else const _Tick.short(),
|
||||
if (value.stopType != StopType.full) const SizedBox(width: Dimens.grid4),
|
||||
];
|
||||
return Row(
|
||||
|
@ -59,3 +47,51 @@ class ExposurePairsListItem<T extends PhotographyStopValue> extends StatelessWid
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _Title<T extends PhotographyStopValue> extends StatelessWidget {
|
||||
final T value;
|
||||
|
||||
const _Title(this.value, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Flexible(
|
||||
child: AutoSizeText(
|
||||
value.toString(),
|
||||
stepGranularity: 0.5,
|
||||
style: labelTextStyle(context).copyWith(color: Theme.of(context).colorScheme.onBackground),
|
||||
softWrap: false,
|
||||
overflow: TextOverflow.fade,
|
||||
maxLines: 1,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
TextStyle labelTextStyle(BuildContext context) {
|
||||
switch (value.stopType) {
|
||||
case StopType.full:
|
||||
return Theme.of(context).textTheme.bodyLarge!;
|
||||
case StopType.half:
|
||||
case StopType.third:
|
||||
return Theme.of(context).textTheme.bodyMedium!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _Tick extends StatelessWidget {
|
||||
final double _length;
|
||||
|
||||
const _Tick.full() : _length = Dimens.grid16;
|
||||
const _Tick.short() : _length = Dimens.grid8;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ColoredBox(
|
||||
color: Theme.of(context).colorScheme.onBackground,
|
||||
child: SizedBox(
|
||||
height: 1,
|
||||
width: _length,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ environment:
|
|||
|
||||
dependencies:
|
||||
app_settings: 4.2.0
|
||||
auto_size_text: 3.0.0
|
||||
bloc_concurrency: 0.2.2
|
||||
camera: 0.10.5+2
|
||||
camera_android_camerax: 0.6.1+1
|
||||
|
|
Loading…
Reference in a new issue