rustdesk/flutter_hbb/lib/home_page.dart

130 lines
3.8 KiB
Dart
Raw Normal View History

2020-11-15 20:04:05 +08:00
import 'package:flutter/material.dart';
2020-11-16 01:13:26 +08:00
import 'package:provider/provider.dart';
2020-11-15 20:04:05 +08:00
import 'common.dart';
import 'remote_page.dart';
2020-11-15 20:04:05 +08:00
class HomePage extends StatefulWidget {
HomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
final _idController = TextEditingController();
2020-11-15 20:04:05 +08:00
2020-11-17 16:53:02 +08:00
@override
void initState() {
super.initState();
_idController.text = FFI.getId();
}
2020-11-15 20:04:05 +08:00
@override
Widget build(BuildContext context) {
2020-11-17 11:12:55 +08:00
Provider.of<FfiModel>(context);
2020-11-15 20:04:05 +08:00
// This method is rerun every time setState is called
return Scaffold(
2020-11-16 01:13:26 +08:00
appBar: AppBar(
title: Text(widget.title),
2020-11-15 20:04:05 +08:00
),
2020-11-16 01:13:26 +08:00
body: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
getSearchBarUI(),
Expanded(child: Container())
]),
color: MyTheme.grayBg,
padding: const EdgeInsets.fromLTRB(16.0, 0.0, 16.0, 0.0),
));
}
void onConnect() {
var id = _idController.text.trim();
if (id == "") return;
Navigator.push<dynamic>(
context,
MaterialPageRoute<dynamic>(
builder: (BuildContext context) => RemotePage(id: id),
),
);
2020-11-15 20:04:05 +08:00
}
Widget getSearchBarUI() {
return Padding(
2020-11-16 01:13:26 +08:00
padding: const EdgeInsets.only(top: 8.0),
child: Container(
height: 84,
child: Padding(
padding: const EdgeInsets.only(top: 8, bottom: 8),
child: Container(
decoration: BoxDecoration(
color: MyTheme.white,
borderRadius: const BorderRadius.only(
bottomRight: Radius.circular(13.0),
bottomLeft: Radius.circular(13.0),
topLeft: Radius.circular(13.0),
topRight: Radius.circular(13.0),
),
),
child: Row(
children: <Widget>[
Expanded(
child: Container(
padding: const EdgeInsets.only(left: 16, right: 16),
child: TextFormField(
style: TextStyle(
fontFamily: 'WorkSans',
fontWeight: FontWeight.bold,
fontSize: 30,
color: Color(0xFF00B6F0),
),
2020-11-16 21:21:27 +08:00
keyboardType: TextInputType.number,
2020-11-16 01:13:26 +08:00
decoration: InputDecoration(
labelText: 'Remote ID',
border: InputBorder.none,
helperStyle: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
color: HexColor('#B9BABC'),
),
labelStyle: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
letterSpacing: 0.2,
color: HexColor('#B9BABC'),
2020-11-15 20:04:05 +08:00
),
),
2020-11-16 01:13:26 +08:00
autofocus: false,
controller: _idController,
2020-11-15 20:04:05 +08:00
),
2020-11-16 01:13:26 +08:00
),
2020-11-15 20:04:05 +08:00
),
2020-11-16 01:13:26 +08:00
SizedBox(
width: 60,
height: 60,
child: IconButton(
icon: Icon(Icons.arrow_forward,
color: HexColor('#B9BABC'), size: 45),
onPressed: onConnect,
),
)
],
2020-11-15 20:04:05 +08:00
),
),
2020-11-16 01:13:26 +08:00
),
2020-11-15 20:04:05 +08:00
),
);
}
2020-11-16 01:13:26 +08:00
@override
void dispose() {
_idController.dispose();
2020-11-16 01:13:26 +08:00
super.dispose();
}
2020-11-15 20:04:05 +08:00
}