This commit is contained in:
lollipopkit
2023-05-08 16:25:31 +08:00
parent a2361da560
commit 7f16c27dcf
25 changed files with 634 additions and 572 deletions

View File

@@ -108,7 +108,7 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildInput(
Input(
controller: _nameController,
type: TextInputType.text,
node: _nameFocus,
@@ -117,17 +117,16 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
label: _s.name,
icon: Icons.info,
),
buildInput(
Input(
controller: _ipController,
type: TextInputType.text,
onSubmitted: (_) => _focusScope.requestFocus(_portFocus),
node: _ipFocus,
autoCorrect: false,
label: _s.host,
icon: Icons.storage,
hint: 'example.com',
),
buildInput(
Input(
controller: _portController,
type: TextInputType.number,
node: _portFocus,
@@ -136,11 +135,10 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
icon: Icons.format_list_numbered,
hint: '22',
),
buildInput(
Input(
controller: _usernameController,
type: TextInputType.text,
node: _usernameFocus,
autoCorrect: false,
label: _s.user,
icon: Icons.account_box,
hint: 'root',
@@ -158,7 +156,7 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
],
),
!usePublicKey
? buildInput(
? Input(
controller: _passwordController,
obscureText: true,
type: TextInputType.text,

View File

@@ -62,38 +62,7 @@ class _ServerPageState extends State<ServerPage>
Widget build(BuildContext context) {
super.build(context);
return Scaffold(
body: RefreshIndicator(
onRefresh: () async =>
await _serverProvider.refreshData(onlyFailed: true),
child: Consumer<ServerProvider>(
builder: (_, pro, __) {
if (pro.servers.isEmpty) {
return Center(
child: Text(
_s.serverTabEmpty,
textAlign: TextAlign.center,
),
);
}
final keys = pro.servers.keys.toList();
return ListView.separated(
padding: const EdgeInsets.fromLTRB(7, 10, 7, 7),
controller: ScrollController(),
physics: const AlwaysScrollableScrollPhysics(),
itemBuilder: (ctx, idx) {
if (idx == pro.servers.length) {
return SizedBox(height: _media.padding.bottom);
}
return _buildEachServerCard(pro.servers[keys[idx]]);
},
itemCount: pro.servers.length,
separatorBuilder: (_, __) => const SizedBox(
height: 3,
),
);
},
),
),
body: _buildBody(),
floatingActionButton: FloatingActionButton(
onPressed: () => AppRoute(
const ServerEditPage(),
@@ -106,6 +75,41 @@ class _ServerPageState extends State<ServerPage>
);
}
Widget _buildBody() {
return RefreshIndicator(
onRefresh: () async =>
await _serverProvider.refreshData(onlyFailed: true),
child: Consumer<ServerProvider>(
builder: (_, pro, __) {
if (pro.servers.isEmpty) {
return Center(
child: Text(
_s.serverTabEmpty,
textAlign: TextAlign.center,
),
);
}
final keys = pro.servers.keys.toList();
return ListView.separated(
padding: const EdgeInsets.fromLTRB(7, 10, 7, 7),
controller: ScrollController(),
physics: const AlwaysScrollableScrollPhysics(),
itemBuilder: (ctx, idx) {
if (idx == pro.servers.length) {
return SizedBox(height: _media.padding.bottom);
}
return _buildEachServerCard(pro.servers[keys[idx]]);
},
itemCount: pro.servers.length,
separatorBuilder: (_, __) => const SizedBox(
height: 3,
),
);
},
),
);
}
Widget _buildEachServerCard(Server? si) {
if (si == null) {
return const SizedBox();