matrix_flutter_app_v2/lib/view/home.dart
2023-11-24 20:35:29 +08:00

94 lines
2.6 KiB
Dart

import 'dart:async';
import 'package:flutter/material.dart';
import 'dart:io' show Platform;
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
Timer? timer;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
toolbarHeight: 35,
title: Text(widget.title),
backgroundColor: Theme.of(context).colorScheme.primary,
),
body: Center(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
const SizedBox(
height: 150,
child: Text(
'You have pushed the button this many times:',
),
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
TextButton(
onPressed: () {
Navigator.pushNamed(context,"/media");
},
child: const Text("to media"),
),
TextButton(
onPressed: () {
Navigator.pushNamed(context,"/video");
},
child: const Text("to video"),
)
],
),
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: FloatingActionButton(
tooltip: 'Increment',
onPressed: () {},
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onLongPressStart: (_) {
timer?.cancel();
Timer.periodic(const Duration(milliseconds: 10), (timer) {
this.timer = timer;
_incrementCounter();
});
debugPrint("onLongPressStart");
},
onLongPressEnd: (_) {
timer?.cancel();
debugPrint("onLongPressEnd");
},
onLongPress: () {
debugPrint("onLongPress");
},
onTap: () {
_incrementCounter();
debugPrint("onTap");
},
child: const Icon(Icons.add),
),
));
}
}