WT1.1.0+38 Design, time_picker
This commit is contained in:
@@ -48,7 +48,7 @@ class MenuInfoWidget extends StatelessWidget with Common {
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withOpacity(0.5),
|
||||
border: Border.all(color: Colors.white60),
|
||||
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
||||
borderRadius: BorderRadius.all(Radius.circular(16.0)),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
||||
@@ -45,7 +45,6 @@ class MenuPageWidget extends StatelessWidget with Trans {
|
||||
}
|
||||
|
||||
final List<Widget> _columnChildren = List();
|
||||
final double distortionHeight = cHeight / baseHeight;
|
||||
|
||||
if (menuBloc.getFilteredBranch(menuBloc.parent).isEmpty) {
|
||||
_columnChildren.add(Container(
|
||||
@@ -57,21 +56,6 @@ class MenuPageWidget extends StatelessWidget with Trans {
|
||||
} else {
|
||||
menuBloc.getFilteredBranch(menuBloc.parent).forEach((treeName, value) {
|
||||
WorkoutMenuTree workoutTree = value;
|
||||
/* double textLength = workoutTree.name.length * workoutTree.fontSize;
|
||||
double top = textLength < cWidth - 30
|
||||
? (cHeight / 3 - 2.5 * workoutTree.fontSize) / distortionHeight
|
||||
: (cHeight / 3 - 3.6 * workoutTree.fontSize) / distortionHeight;
|
||||
|
||||
print(" dH: " +
|
||||
distortionHeight.toStringAsFixed(1) +
|
||||
" W: " +
|
||||
cWidth.toStringAsFixed(0) +
|
||||
" H: " +
|
||||
cHeight.toStringAsFixed(0) +
|
||||
" TOP: " +
|
||||
top.toStringAsFixed(0) +
|
||||
" tL: " +
|
||||
textLength.toStringAsFixed(0)); */
|
||||
_columnChildren.add(Container(
|
||||
padding: EdgeInsets.only(top: 15.0, left: 15, right: 15),
|
||||
height: 225, //cHeight / 3 * distortionHeight,
|
||||
@@ -94,15 +78,14 @@ class MenuPageWidget extends StatelessWidget with Trans {
|
||||
onPressed: () => menuClick(workoutTree, menuBloc, context),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 15, bottom: 10),
|
||||
child: InkWell(
|
||||
padding: EdgeInsets.only(left: 15, bottom: 15, right: 15),
|
||||
child: GestureDetector(
|
||||
onTap: () => menuClick(workoutTree, menuBloc, context),
|
||||
child: Text(
|
||||
workoutTree.name,
|
||||
maxLines: 3,
|
||||
maxLines: 4,
|
||||
style: GoogleFonts.archivoBlack(color: workoutTree.color, fontSize: workoutTree.fontSize, height: 1.1),
|
||||
),
|
||||
highlightColor: workoutTree.color,
|
||||
),
|
||||
),
|
||||
]))));
|
||||
@@ -111,12 +94,6 @@ class MenuPageWidget extends StatelessWidget with Trans {
|
||||
|
||||
SliverList sliverList = SliverList(
|
||||
delegate: SliverChildListDelegate(_columnChildren),
|
||||
/* gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 1,
|
||||
mainAxisSpacing: 6.0,
|
||||
crossAxisSpacing: 10.0,
|
||||
childAspectRatio: cWidth > 375 ? 1.8 : 1.8,
|
||||
) */
|
||||
);
|
||||
|
||||
slivers.add(sliverList);
|
||||
@@ -165,7 +142,6 @@ class MenuPageWidget extends StatelessWidget with Trans {
|
||||
menuBloc.exerciseDeviceRepository.getGymDevices().forEach((element) {
|
||||
String deviceName = AppLanguage().appLocal == Locale('en') ? element.name : element.nameTranslation;
|
||||
ChoiceChip chip = ChoiceChip(
|
||||
//padding: EdgeInsets.zero,
|
||||
labelPadding: EdgeInsets.only(right: 5),
|
||||
avatar: Icon(
|
||||
Icons.remove_circle_outline,
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
import 'package:aitrainer_app/util/trans.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TimePickerWidget extends StatefulWidget {
|
||||
final Function(double) onChange;
|
||||
|
||||
const TimePickerWidget({Key key, this.onChange}) : super(key: key);
|
||||
@override
|
||||
_TimePickerWidgetState createState() => _TimePickerWidgetState();
|
||||
}
|
||||
|
||||
class _TimePickerWidgetState extends State<TimePickerWidget> with Trans {
|
||||
Widget durationPicker({bool inSeconds = false, bool inHundredths = false}) {
|
||||
double seconds = 0;
|
||||
return CupertinoPicker(
|
||||
scrollController: FixedExtentScrollController(initialItem: 0),
|
||||
backgroundColor: Colors.transparent,
|
||||
onSelectedItemChanged: (x) {
|
||||
if (inSeconds) {
|
||||
currentTimeInSec = x.toDouble();
|
||||
} else if (inHundredths) {
|
||||
currentTimeInDec = x.toDouble();
|
||||
} else {
|
||||
currentTimeInMin = x.toDouble();
|
||||
}
|
||||
seconds = currentTimeInMin * 60 + currentTimeInSec + currentTimeInDec / 100;
|
||||
//print("sec" + seconds.toStringAsFixed(2));
|
||||
setState(() {});
|
||||
widget.onChange(seconds);
|
||||
},
|
||||
children: List.generate(
|
||||
inSeconds
|
||||
? 60
|
||||
: inHundredths
|
||||
? 100
|
||||
: 60,
|
||||
(index) => Text(
|
||||
inSeconds
|
||||
? '$index sec'
|
||||
: inHundredths
|
||||
? index.toString() + ' "'
|
||||
: '$index min',
|
||||
style: TextStyle(color: Colors.yellow[200]))),
|
||||
itemExtent: 40,
|
||||
);
|
||||
}
|
||||
|
||||
double currentTimeInSec = 0;
|
||||
double currentTimeInMin = 0;
|
||||
double currentTimeInDec = 0;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
setContext(context);
|
||||
return Container(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
color: Colors.transparent,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: Center(
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
width: MediaQuery.of(context).size.width * 0.95,
|
||||
height: MediaQuery.of(context).size.height * 0.25,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(child: durationPicker()),
|
||||
Expanded(child: durationPicker(inSeconds: true)),
|
||||
Expanded(child: durationPicker(inHundredths: true)),
|
||||
],
|
||||
)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user