Added a display widget
This commit is contained in:
parent
e9a7a669fa
commit
1d88ba6873
4 changed files with 29 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -27,3 +27,4 @@ doc/api/
|
|||
.flutter-plugins
|
||||
.flutter-plugins-dependencies
|
||||
|
||||
projects/chrono/lib/TPSIT_25-26.code-workspace
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ class _StopwatchControlsState extends State<StopwatchControls> {
|
|||
|
||||
void _setIcons(){
|
||||
setState(() {
|
||||
print(_state);
|
||||
switch(_state){
|
||||
case StopwatchStates.started:
|
||||
_button1Icon = Icon(Icons.stop);
|
||||
|
|
|
|||
25
projects/chrono/lib/display.dart
Normal file
25
projects/chrono/lib/display.dart
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class Display extends StatelessWidget {
|
||||
final int seconds;
|
||||
|
||||
const Display({
|
||||
Key? key,
|
||||
required this.seconds,
|
||||
}) : super(key: key);
|
||||
|
||||
String formatTime(seconds){
|
||||
return '${(seconds / 60 / 60).floor() % 60}:${(seconds / 60).floor() % 60}:${seconds.floor() % 60}';
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Text(
|
||||
formatTime(seconds),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 100,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'controls.dart';
|
||||
import 'display.dart';
|
||||
|
||||
void main(){
|
||||
runApp(MyApp());
|
||||
|
|
@ -21,9 +22,9 @@ class MyApp extends StatelessWidget {
|
|||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 50,
|
||||
children: [
|
||||
// Stopwatch display
|
||||
// +
|
||||
Display(seconds: 6767),
|
||||
StopwatchControls(),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue