Browse Source

add some back UI

pull/18/head
Sun 4 years ago
parent
commit
2d69a45bbf
  1. 200
      lib/apps/chat/add.dart
  2. 14
      lib/apps/chat/list.dart
  3. 14
      lib/apps/file/list.dart
  4. 35
      lib/apps/group_chat/add.dart
  5. 14
      lib/apps/group_chat/list.dart
  6. 4
      lib/apps/group_chat/provider.dart
  7. 32
      lib/apps/service/list.dart
  8. 14
      lib/pages/home.dart
  9. 4
      src/apps/group_chat/layer.rs

200
lib/apps/chat/add.dart

@ -17,6 +17,7 @@ import 'package:esse/global.dart'; @@ -17,6 +17,7 @@ import 'package:esse/global.dart';
import 'package:esse/provider.dart';
import 'package:esse/apps/chat/models.dart';
import 'package:esse/apps/chat/list.dart';
import 'package:esse/apps/chat/provider.dart';
class ChatAddPage extends StatefulWidget {
@ -31,7 +32,6 @@ class ChatAddPage extends StatefulWidget { @@ -31,7 +32,6 @@ class ChatAddPage extends StatefulWidget {
}
class _ChatAddPageState extends State<ChatAddPage> {
final _formKey = GlobalKey<FormState>();
TextEditingController userIdEditingController = TextEditingController();
TextEditingController addrEditingController = TextEditingController();
TextEditingController remarkEditingController = TextEditingController();
@ -115,113 +115,101 @@ class _ChatAddPageState extends State<ChatAddPage> { @@ -115,113 +115,101 @@ class _ChatAddPageState extends State<ChatAddPage> {
final requestKeys = requests.keys.toList().reversed.toList(); // it had sorted.
return Scaffold(
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(children: <Widget>[
Row(
children: [
if (!isDesktop)
GestureDetector(
onTap: () {
context.read<ChatProvider>().requestClear();
Navigator.pop(context);
},
child: Container(
width: 20.0,
child: Icon(Icons.arrow_back, color: color.primary)),
),
SizedBox(width: 15.0),
Expanded(
child: Text(lang.addFriend,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0)),
),
TextButton(
onPressed: () => showShadowDialog(
context,
Icons.info,
lang.info,
UserInfo(app: 'add-friend',
id: account.id, name: account.name, addr: Global.addr)
),
child: Text(lang.myQrcode, style: TextStyle(fontSize: 16.0)),
),
],
),
isDesktop ? SizedBox(height: 20.0) : SizedBox(height: 50.0),
Expanded(
child: SingleChildScrollView(
child: Container(
constraints: BoxConstraints(minWidth: 200, maxWidth: 600),
padding: const EdgeInsets.all(20),
child: Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ShadowButton(
icon: Icons.camera_alt,
color: color,
text: lang.scanQr,
action: () => Navigator.push(
context,
MaterialPageRoute(builder: (context) => QRScan(callback: scanCallback))
)),
if (MediaQuery.of(context).size.width < 400) Spacer(),
ShadowButton(
icon: Icons.image,
color: color,
text: lang.scanImage,
action: chooseImage),
],
),
),
const SizedBox(height: 40.0),
InputText(
icon: Icons.person,
text: lang.id,
controller: userIdEditingController,
focus: userIdFocus),
const SizedBox(height: 20.0),
InputText(
icon: Icons.location_on,
text: lang.address,
controller: addrEditingController,
focus: addrFocus),
const SizedBox(height: 20.0),
InputText(
icon: Icons.turned_in,
text: lang.remark,
controller: remarkEditingController,
focus: remarkFocus),
const SizedBox(height: 20.0),
ButtonText(action: send, text: lang.send, width: 600.0),
const SizedBox(height: 20.0),
const Divider(height: 1.0, color: Color(0x40ADB0BB)),
const SizedBox(height: 10.0),
if (requests.isNotEmpty)
ListView.builder(
itemCount: requestKeys.length,
shrinkWrap: true,
physics: ClampingScrollPhysics(),
scrollDirection: Axis.vertical,
itemBuilder: (BuildContext context, int index) =>
_RequestItem(request: requests[requestKeys[index]]),
),
],
),
),
appBar: AppBar(
title: Text(lang.addFriend),
bottom: PreferredSize(
child: Container(color: const Color(0x40ADB0BB), height: 1.0),
preferredSize: Size.fromHeight(1.0)
),
leading: isDesktop
? IconButton(
onPressed: () {
context.read<ChatProvider>().requestClear();
context.read<AccountProvider>().updateActivedWidget(ChatList());
},
icon: Icon(Icons.arrow_back, color: color.primary),
) : null,
actions: [
TextButton(
onPressed: () => showShadowDialog(
context,
Icons.info,
lang.info,
UserInfo(app: 'add-friend',
id: account.id, name: account.name, addr: Global.addr)
),
child: Text(lang.myQrcode, style: TextStyle(fontSize: 16.0)),
),
]
),
body: Container(
padding: const EdgeInsets.all(10.0),
alignment: Alignment.topCenter,
child: SingleChildScrollView(
child: Container(
width: 600,
padding: const EdgeInsets.all(20),
child: Column(
children: <Widget>[
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ShadowButton(
icon: Icons.camera_alt,
color: color,
text: lang.scanQr,
action: () => Navigator.push(
context,
MaterialPageRoute(builder: (context) => QRScan(callback: scanCallback))
)),
if (MediaQuery.of(context).size.width < 400) Spacer(),
ShadowButton(
icon: Icons.image,
color: color,
text: lang.scanImage,
action: chooseImage),
],
),
),
),
]
)
)
));
const SizedBox(height: 40.0),
InputText(
icon: Icons.person,
text: lang.id,
controller: userIdEditingController,
focus: userIdFocus),
const SizedBox(height: 20.0),
InputText(
icon: Icons.location_on,
text: lang.address,
controller: addrEditingController,
focus: addrFocus),
const SizedBox(height: 20.0),
InputText(
icon: Icons.turned_in,
text: lang.remark,
controller: remarkEditingController,
focus: remarkFocus),
const SizedBox(height: 20.0),
ButtonText(action: send, text: lang.send, width: 600.0),
const SizedBox(height: 20.0),
const Divider(height: 1.0, color: Color(0x40ADB0BB)),
const SizedBox(height: 10.0),
if (requests.isNotEmpty)
ListView.builder(
itemCount: requestKeys.length,
shrinkWrap: true,
physics: ClampingScrollPhysics(),
scrollDirection: Axis.vertical,
itemBuilder: (BuildContext context, int index) =>
_RequestItem(request: requests[requestKeys[index]]),
),
],
),
),
),
),
);
}
}

14
lib/apps/chat/list.dart

@ -36,14 +36,12 @@ class _ChatListState extends State<ChatList> { @@ -36,14 +36,12 @@ class _ChatListState extends State<ChatList> {
preferredSize: Size.fromHeight(1.0)
),
),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: ListView.builder(
itemCount: chatKeys.length,
itemBuilder: (BuildContext ctx, int index) => ListChat(friend: friends[chatKeys[index]]),
)
),
body: Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: ListView.builder(
itemCount: chatKeys.length,
itemBuilder: (BuildContext ctx, int index) => ListChat(friend: friends[chatKeys[index]]),
)
),
floatingActionButton: FloatingActionButton(
onPressed: () {

14
lib/apps/file/list.dart

@ -83,14 +83,12 @@ class _FilesListState extends State<FilesList> { @@ -83,14 +83,12 @@ class _FilesListState extends State<FilesList> {
preferredSize: Size.fromHeight(1.0)
),
),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: ListView.builder(
itemCount: FILE_DIRECTORY.length,
itemBuilder: (BuildContext ctx, int index) => item(index, color, isDesktop),
)
),
body: Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: ListView.builder(
itemCount: FILE_DIRECTORY.length,
itemBuilder: (BuildContext ctx, int index) => item(index, color, isDesktop),
)
),
);
}

35
lib/apps/group_chat/add.dart

@ -18,6 +18,7 @@ import 'package:esse/rpc.dart'; @@ -18,6 +18,7 @@ import 'package:esse/rpc.dart';
import 'package:esse/provider.dart';
import 'package:esse/apps/group_chat/models.dart';
import 'package:esse/apps/group_chat/list.dart';
import 'package:esse/apps/group_chat/provider.dart';
class GroupAddPage extends StatefulWidget {
@ -220,26 +221,28 @@ class _GroupAddPageState extends State<GroupAddPage> { @@ -220,26 +221,28 @@ class _GroupAddPageState extends State<GroupAddPage> {
final requests = provider.requests;
final requestKeys = requests.keys.toList().reversed.toList();
return SafeArea(
child: DefaultTabController(
return DefaultTabController(
initialIndex: 0,
length: 2,
child: Scaffold(
appBar: AppBar(
title: Row(
children: [
Expanded(
child: Text(lang.groupChatAdd,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0)),
),
TextButton(
onPressed: () => Navigator.push(context,
MaterialPageRoute(builder: (context) => QRScan(callback: _scanCallback))
),
child: Text(lang.scanQr, style: TextStyle(fontSize: 16.0)),
title: Text(lang.addFriend),
leading: isDesktop
? IconButton(
onPressed: () {
context.read<GroupChatProvider>().requestClear();
context.read<AccountProvider>().updateActivedWidget(GroupChatList());
},
icon: Icon(Icons.arrow_back, color: color.primary),
) : null,
actions: [
TextButton(
onPressed: () => Navigator.push(context,
MaterialPageRoute(builder: (context) => QRScan(callback: _scanCallback))
),
],
),
child: Text(lang.scanQr, style: TextStyle(fontSize: 16.0)),
),
],
bottom: TabBar(
tabs: <Widget>[
Tab(
@ -531,7 +534,7 @@ class _GroupAddPageState extends State<GroupAddPage> { @@ -531,7 +534,7 @@ class _GroupAddPageState extends State<GroupAddPage> {
),
),
],
)))
))
);
}
}

14
lib/apps/group_chat/list.dart

@ -35,14 +35,12 @@ class _GroupChatListState extends State<GroupChatList> { @@ -35,14 +35,12 @@ class _GroupChatListState extends State<GroupChatList> {
preferredSize: Size.fromHeight(1.0)
),
),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: ListView.builder(
itemCount: orderKeys.length,
itemBuilder: (BuildContext ctx, int index) => ListChat(group: groups[orderKeys[index]]),
)
),
body: Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: ListView.builder(
itemCount: orderKeys.length,
itemBuilder: (BuildContext ctx, int index) => ListChat(group: groups[orderKeys[index]]),
)
),
floatingActionButton: FloatingActionButton(
onPressed: () {

4
lib/apps/group_chat/provider.dart

@ -118,6 +118,10 @@ class GroupChatProvider extends ChangeNotifier { @@ -118,6 +118,10 @@ class GroupChatProvider extends ChangeNotifier {
this.activedMembers.clear();
}
requestClear() {
this.requests.clear();
}
join(GroupType gtype, String gid, String gaddr, String name, String remark, [String proof = '', String key = '']) {
rpc.send('group-chat-join', [gtype.toInt(), gid, gaddr, name, remark, proof, key]);
}

32
lib/apps/service/list.dart

@ -35,23 +35,21 @@ class _ServiceListState extends State<ServiceList> { @@ -35,23 +35,21 @@ class _ServiceListState extends State<ServiceList> {
preferredSize: Size.fromHeight(1.0)
),
),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: ListView.builder(
itemCount: INNER_SERVICES.length,
itemBuilder: (BuildContext ctx, int index) {
final params = INNER_SERVICES[index].params(lang);
return ListInnerService(
name: params[0],
bio: params[1],
logo: params[2],
callback: () => INNER_SERVICES[index].callback(),
isDesktop: isDesktop,
);
}
)
),
body: Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: ListView.builder(
itemCount: INNER_SERVICES.length,
itemBuilder: (BuildContext ctx, int index) {
final params = INNER_SERVICES[index].params(lang);
return ListInnerService(
name: params[0],
bio: params[1],
logo: params[2],
callback: () => INNER_SERVICES[index].callback(),
isDesktop: isDesktop,
);
}
)
),
floatingActionButton: FloatingActionButton(
onPressed: () {

14
lib/pages/home.dart

@ -212,14 +212,12 @@ class _HomeListState extends State<HomeList> { @@ -212,14 +212,12 @@ class _HomeListState extends State<HomeList> {
)
]
),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: ListView.builder(
itemCount: allKeys.length,
itemBuilder: (BuildContext ctx, int index) => _SessionWidget(
session: sessions[allKeys[index]]
),
body: Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: ListView.builder(
itemCount: allKeys.length,
itemBuilder: (BuildContext ctx, int index) => _SessionWidget(
session: sessions[allKeys[index]]
),
),
),

4
src/apps/group_chat/layer.rs

@ -213,7 +213,7 @@ async fn handle_event( @@ -213,7 +213,7 @@ async fn handle_event(
results.rpcs.push(rpc::member_offline(mgid, gid, mid));
}
LayerEvent::Sync(gcd, height, event) => {
let (sid, gid) = layer.read().await.get_running_remote_id(&mgid, &gcd)?;
let (_sid, gid) = layer.read().await.get_running_remote_id(&mgid, &gcd)?;
println!("Sync: height: {}", height);
let base = layer.read().await.base().clone();
@ -312,7 +312,7 @@ async fn handle_event( @@ -312,7 +312,7 @@ async fn handle_event(
let (_sid, _gid) = layer.read().await.get_running_remote_id(&mgid, &gcd)?;
let db = group_chat_db(layer.read().await.base(), &mgid)?;
let id = Request::over_rid(&db, &gcd, &rid, ok)?;
results.rpcs.push(rpc::request_handle(mgid, id, ok));
results.rpcs.push(rpc::request_handle(mgid, id, ok, false));
}
LayerEvent::Request(..) => {} // nerver here.
LayerEvent::Check => {} // nerver here.

Loading…
Cancel
Save