Skip to content

Commit

Permalink
divided title
Browse files Browse the repository at this point in the history
  • Loading branch information
IoTServ committed Mar 4, 2024
1 parent cc65b58 commit fc78d95
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 34 deletions.
40 changes: 26 additions & 14 deletions lib/pages/commonDevice/commonDeviceListPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,25 @@ class _CommonDeviceListPageState extends State<CommonDeviceListPage> {
);
},
);
final divided = ListTile.divideTiles(
context: context,
tiles: tiles,
).toList();
final divided = ListView.separated(
itemCount: tiles.length,
itemBuilder: (context, index) {
return tiles.elementAt(index);
},
separatorBuilder: (context, index) {
return const Divider(
indent: 50,
);
},
);
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
centerTitle: true,
actions: _build_actions(),
),
body: divided.isNotEmpty
? ListView(children: divided)
body: tiles.isNotEmpty
? divided
: Container(
child: Column(children: [
ThemeUtils.isDarkMode(context)
Expand Down Expand Up @@ -215,7 +222,7 @@ class _CommonDeviceListPageState extends State<CommonDeviceListPage> {

void _addRemoteHostFromSession() {
getAllSession().then((v) {
final titles = _SessionList.map(
final tiles = _SessionList.map(
(pair) {
var listItemContent = Padding(
padding: const EdgeInsets.fromLTRB(10.0, 15.0, 10.0, 15.0),
Expand All @@ -241,17 +248,22 @@ class _CommonDeviceListPageState extends State<CommonDeviceListPage> {
);
},
);
final divided = ListTile.divideTiles(
context: context,
tiles: titles,
).toList();
final divided = ListView.separated(
itemCount: tiles.length,
itemBuilder: (context, index) {
return tiles.elementAt(index);
},
separatorBuilder: (context, index) {
return const Divider(
indent: 50,
);
},
);
showDialog(
context: context,
builder: (_) => AlertDialog(
title: const Text("请选择远程主机所在网络:"),
content: ListView(
children: divided,
),
content: divided,
actions: <Widget>[
TextButton(
child: const Text("取消"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:flutter/material.dart';

// import 'package:oktoast/oktoast.dart';
import 'package:openiothub/model/custom_theme.dart';
import 'package:openiothub/pages/session/sessionmDNSServiceListPage.dart';
import './mDNSServiceListPage.dart';
import 'package:openiothub/util/ThemeUtils.dart';
import 'package:openiothub_api/api/OpenIoTHub/SessionApi.dart';
import 'package:openiothub_api/openiothub_api.dart';
Expand All @@ -18,17 +18,17 @@ import 'package:provider/provider.dart';
import '../../generated/l10n.dart';
import '../commonPages/scanQR.dart';

class SessionListPage extends StatefulWidget {
const SessionListPage({required Key key, required this.title})
class GatewayListPage extends StatefulWidget {
const GatewayListPage({required Key key, required this.title})
: super(key: key);

final String title;

@override
_SessionListPageState createState() => _SessionListPageState();
_GatewayListPageState createState() => _GatewayListPageState();
}

class _SessionListPageState extends State<SessionListPage> {
class _GatewayListPageState extends State<GatewayListPage> {
static const double IMAGE_ICON_WIDTH = 30.0;

List<SessionConfig> _SessionList = [];
Expand Down Expand Up @@ -75,18 +75,25 @@ class _SessionListPageState extends State<SessionListPage> {
);
},
);
final divided = ListTile.divideTiles(
context: context,
tiles: tiles,
).toList();
final divided = ListView.separated(
itemCount: tiles.length,
itemBuilder: (context, index) {
return tiles.elementAt(index);
},
separatorBuilder: (context, index) {
return const Divider(
indent: 50,
);
},
);
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
centerTitle: true,
actions: _build_actions(),
),
body: divided.isNotEmpty
? ListView(children: divided)
body: tiles.isNotEmpty
? divided
: Column(children: [
ThemeUtils.isDarkMode(context)
? Center(child: Image.asset('assets/images/empty_list_black.png'),)
Expand Down
File renamed without changes.
5 changes: 2 additions & 3 deletions lib/pages/homePage/homePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:openiothub/generated/l10n.dart';
import 'package:openiothub/pages/mdnsService/mdnsServiceListPage.dart';
import 'package:openiothub/pages/session/sessionListPage.dart';
import 'package:openiothub/pages/user/profilePage.dart';

import '../commonDevice/commonDeviceListPage.dart';
import '../commonPages/scanQR.dart';
import '../gateway/gatewayListPage.dart';

class MyHomePage extends StatefulWidget {
const MyHomePage({required Key key, required this.title}) : super(key: key);
Expand Down Expand Up @@ -94,7 +93,7 @@ class _MyHomePageState extends State<MyHomePage> with WidgetsBindingObserver {
);
break;
case 1:
return SessionListPage(
return GatewayListPage(
title: S.current.tab_gateway,
key: UniqueKey(),
);
Expand Down
19 changes: 13 additions & 6 deletions lib/pages/mdnsService/mdnsServiceListPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,25 @@ class _MdnsServiceListPageState extends State<MdnsServiceListPage> {
);
},
);
final divided = ListTile.divideTiles(
context: context,
tiles: tiles,
).toList();
final divided = ListView.separated(
itemCount: tiles.length,
itemBuilder: (context, index) {
return tiles.elementAt(index);
},
separatorBuilder: (context, index) {
return const Divider(
indent: 50,
);
},
);
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
centerTitle: true,
actions: _build_actions(),
),
body: divided.isNotEmpty
? ListView(children: divided)
body: tiles.isNotEmpty
? divided
: Container(
child: Column(children: [
ThemeUtils.isDarkMode(context)
Expand Down

0 comments on commit fc78d95

Please sign in to comment.