Initial commit
This commit is contained in:
commit
b5f2ecd56f
96 changed files with 4522 additions and 0 deletions
59
lib/components/dialogs/new_group_dialog.dart
Normal file
59
lib/components/dialogs/new_group_dialog.dart
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
import 'package:fluffychat/views/chat.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../matrix.dart';
|
||||
|
||||
class NewGroupDialog extends StatelessWidget {
|
||||
final TextEditingController controller = TextEditingController();
|
||||
|
||||
void submitAction(BuildContext context) async {
|
||||
final MatrixState matrix = Matrix.of(context);
|
||||
Map<String, dynamic> params = {};
|
||||
if (controller.text.isNotEmpty) params["name"] = controller.text;
|
||||
final String roomID = await matrix.tryRequestWithLoadingDialog(
|
||||
matrix.client.createRoom(params: params),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
if (roomID != null)
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => Chat(roomID)),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text("Create new group"),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
TextField(
|
||||
controller: controller,
|
||||
autofocus: true,
|
||||
autocorrect: false,
|
||||
textInputAction: TextInputAction.go,
|
||||
onSubmitted: (s) => submitAction(context),
|
||||
decoration: InputDecoration(
|
||||
labelText: "Group name",
|
||||
icon: Icon(Icons.people),
|
||||
hintText: "Enter a group name"),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
child: Text("Close".toUpperCase(),
|
||||
style: TextStyle(color: Colors.blueGrey)),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
FlatButton(
|
||||
child: Text("Create".toUpperCase()),
|
||||
onPressed: () => submitAction(context),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
72
lib/components/dialogs/new_private_chat_dialog.dart
Normal file
72
lib/components/dialogs/new_private_chat_dialog.dart
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/views/chat.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../matrix.dart';
|
||||
|
||||
class NewPrivateChatDialog extends StatelessWidget {
|
||||
final TextEditingController controller = TextEditingController();
|
||||
|
||||
void submitAction(BuildContext context) async {
|
||||
if (controller.text.isEmpty) return;
|
||||
final MatrixState matrix = Matrix.of(context);
|
||||
final User user = User(
|
||||
"@" + controller.text,
|
||||
room: Room(id: "", client: matrix.client),
|
||||
);
|
||||
final String roomID =
|
||||
await matrix.tryRequestWithLoadingDialog(user.startDirectChat());
|
||||
Navigator.of(context).pop();
|
||||
|
||||
if (roomID != null)
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => Chat(roomID)),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text("New private chat"),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
TextField(
|
||||
controller: controller,
|
||||
autofocus: true,
|
||||
autocorrect: false,
|
||||
textInputAction: TextInputAction.go,
|
||||
onSubmitted: (s) => submitAction(context),
|
||||
decoration: InputDecoration(
|
||||
labelText: "Enter a username",
|
||||
icon: Icon(Icons.account_circle),
|
||||
prefixText: "@",
|
||||
hintText: "username:homeserver"),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
"Your username is ${Matrix.of(context).client.userID}",
|
||||
style: TextStyle(
|
||||
color: Colors.blueGrey,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
child: Text("Close".toUpperCase(),
|
||||
style: TextStyle(color: Colors.blueGrey)),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
FlatButton(
|
||||
child: Text("Continue".toUpperCase()),
|
||||
onPressed: () => submitAction(context),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
32
lib/components/dialogs/redact_message_dialog.dart
Normal file
32
lib/components/dialogs/redact_message_dialog.dart
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../matrix.dart';
|
||||
|
||||
class RedactMessageDialog extends StatelessWidget {
|
||||
final Event event;
|
||||
const RedactMessageDialog(this.event);
|
||||
|
||||
void removeAction(BuildContext context) {
|
||||
Matrix.of(context).tryRequestWithLoadingDialog(event.redact());
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text("Message will be removed for all participants"),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
child: Text("Close".toUpperCase(),
|
||||
style: TextStyle(color: Colors.blueGrey)),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
FlatButton(
|
||||
child: Text("Remove".toUpperCase()),
|
||||
onPressed: () => removeAction(context),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue