Merge pull request 'Group Settings Stub' (#54) from groups into trunk
continuous-integration/drone/push Build encountered an error
Details
continuous-integration/drone/push Build encountered an error
Details
Reviewed-on: #54
This commit is contained in:
commit
f0d873a011
|
@ -165,6 +165,13 @@ class MainActivity: FlutterActivity() {
|
|||
val bundle = (call.argument("bundle") as? String) ?: "";
|
||||
Cwtch.blockContact(profile, bundle);
|
||||
}
|
||||
"SetGroupAttribute" -> {
|
||||
val profile = (call.argument("ProfileOnion") as? String) ?: "";
|
||||
val groupHandle = (call.argument("groupHandle") as? String) ?: "";
|
||||
val key = (call.argument("key") as? String) ?: "";
|
||||
val value = (call.argument("value") as? String) ?: "";
|
||||
Cwtch.setGroupAttribute(profile, groupHandle, key, value);
|
||||
}
|
||||
else -> result.notImplemented()
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -44,6 +44,8 @@ abstract class Cwtch {
|
|||
|
||||
// ignore: non_constant_identifier_names
|
||||
void ImportBundle(String profile, String bundle);
|
||||
// ignore: non_constant_identifier_names
|
||||
void SetGroupAttribute(String profile, String groupHandle, String key, String value);
|
||||
|
||||
void dispose();
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@ typedef VoidFromStringStringFn = void Function(Pointer<Utf8>, int, Pointer<Utf8>
|
|||
typedef void_from_string_string_string_function = Void Function(Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Pointer<Utf8>, Int32);
|
||||
typedef VoidFromStringStringStringFn = void Function(Pointer<Utf8>, int, Pointer<Utf8>, int, Pointer<Utf8>, int);
|
||||
|
||||
typedef void_from_string_string_string_string_function = Void Function(Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Pointer<Utf8>, Int32);
|
||||
typedef VoidFromStringStringStringStringFn = void Function(Pointer<Utf8>, int, Pointer<Utf8>, int, Pointer<Utf8>, int, Pointer<Utf8>, int);
|
||||
|
||||
typedef access_cwtch_eventbus_function = Void Function();
|
||||
typedef NextEventFn = void Function();
|
||||
|
||||
|
@ -316,4 +319,17 @@ class CwtchFfi implements Cwtch {
|
|||
final u2 = bundle.toNativeUtf8();
|
||||
ImportBundle(u1, u1.length, u2, u2.length);
|
||||
}
|
||||
|
||||
@override
|
||||
// ignore: non_constant_identifier_names
|
||||
void SetGroupAttribute(String profileOnion, String groupHandle, String key, String value) {
|
||||
var setGroupAttribute = library.lookup<NativeFunction<void_from_string_string_string_string_function>>("c_SetGroupAttribute");
|
||||
// ignore: non_constant_identifier_names
|
||||
final SetGroupAttribute = setGroupAttribute.asFunction<VoidFromStringStringStringStringFn>();
|
||||
final u1 = profileOnion.toNativeUtf8();
|
||||
final u2 = groupHandle.toNativeUtf8();
|
||||
final u3 = key.toNativeUtf8();
|
||||
final u4 = value.toNativeUtf8();
|
||||
SetGroupAttribute(u1, u1.length, u2, u2.length, u3, u3.length, u4, u4.length);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,4 +154,9 @@ class CwtchGomobile implements Cwtch {
|
|||
void ImportBundle(String profileOnion, String bundle) {
|
||||
cwtchPlatform.invokeMethod("ImportBundle", {"ProfileOnion": profileOnion, "bundle": bundle});
|
||||
}
|
||||
|
||||
@override
|
||||
void SetGroupAttribute(String profileOnion, String groupHandle, String key, String value) {
|
||||
cwtchPlatform.invokeMethod("SetGroupAttribute", {"ProfileOnion": profileOnion, "groupHandle": groupHandle, "key": key, "value": value});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
import 'dart:convert';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_app/model.dart';
|
||||
import 'package:flutter_app/widgets/buttontextfield.dart';
|
||||
import 'package:flutter_app/widgets/cwtchlabel.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_app/settings.dart';
|
||||
import 'package:flutter_app/widgets/textfield.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
import '../main.dart';
|
||||
|
||||
/// Group Settings View Provides way to Configure group settings
|
||||
class GroupSettingsView extends StatefulWidget {
|
||||
@override
|
||||
_GroupSettingsViewState createState() => _GroupSettingsViewState();
|
||||
}
|
||||
|
||||
class _GroupSettingsViewState extends State<GroupSettingsView> {
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
final ctrlrNick = TextEditingController(text: "");
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final nickname = Provider.of<ContactInfoState>(context, listen: false).nickname;
|
||||
if (nickname.isNotEmpty) {
|
||||
ctrlrNick.text = nickname;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(Provider.of<ContactInfoState>(context).nickname + " " + AppLocalizations.of(context).conversationSettings),
|
||||
),
|
||||
body: _buildSettingsList(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSettingsList() {
|
||||
return Consumer<Settings>(builder: (context, settings, child) {
|
||||
return LayoutBuilder(builder: (BuildContext context, BoxConstraints viewportConstraints) {
|
||||
return Scrollbar(
|
||||
isAlwaysShown: true,
|
||||
child: SingleChildScrollView(
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minHeight: viewportConstraints.maxHeight,
|
||||
),
|
||||
child: Container(
|
||||
margin: EdgeInsets.all(30),
|
||||
padding: EdgeInsets.all(20),
|
||||
child: Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.stretch, children: [
|
||||
// Address Copy Button
|
||||
Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
CwtchLabel(label: AppLocalizations.of(context).groupAddr),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
CwtchTextField(
|
||||
controller: TextEditingController(text: Provider.of<ContactInfoState>(context, listen: false).onion),
|
||||
)
|
||||
]),
|
||||
// Nickname Save Button
|
||||
Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
CwtchLabel(label: AppLocalizations.of(context).displayNameLabel),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
CwtchButtonTextField(
|
||||
controller: ctrlrNick,
|
||||
readonly: false,
|
||||
onPressed: () {
|
||||
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
||||
var handle = Provider.of<ContactInfoState>(context, listen: false).onion;
|
||||
Provider.of<ContactInfoState>(context, listen: false).nickname = ctrlrNick.text;
|
||||
Provider.of<FlwtchState>(context, listen: false).cwtch.SetGroupAttribute(profileOnion, handle, "local.name", ctrlrNick.text);
|
||||
},
|
||||
icon: Icon(Icons.save),
|
||||
tooltip: AppLocalizations.of(context).saveBtn,
|
||||
)
|
||||
]),
|
||||
Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
CwtchLabel(label: AppLocalizations.of(context).conversationSettings),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
// TODO
|
||||
]),
|
||||
])))));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void _copyOnion() {
|
||||
Clipboard.setData(new ClipboardData(text: Provider.of<ContactInfoState>(context, listen: false).onion));
|
||||
final snackBar = SnackBar(content: Text(AppLocalizations.of(context).copiedClipboardNotification));
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ import '../model.dart';
|
|||
import '../opaque.dart';
|
||||
import '../settings.dart';
|
||||
import '../widgets/messagelist.dart';
|
||||
import 'groupsettingsview.dart';
|
||||
|
||||
class MessageView extends StatefulWidget {
|
||||
@override
|
||||
|
@ -38,7 +39,7 @@ class _MessageViewState extends State<MessageView> {
|
|||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(Provider.of<ContactInfoState>(context).onion),
|
||||
title: Text(Provider.of<ContactInfoState>(context).nickname),
|
||||
actions: [
|
||||
IconButton(icon: Icon(Icons.chat), onPressed: _pushContactSettings),
|
||||
IconButton(icon: Icon(Icons.list), onPressed: _pushContactSettings),
|
||||
|
@ -61,10 +62,10 @@ class _MessageViewState extends State<MessageView> {
|
|||
void _pushContactSettings() {
|
||||
Navigator.of(context).push(MaterialPageRoute<void>(
|
||||
builder: (BuildContext bcontext) {
|
||||
if (Provider.of<FlwtchState>(context, listen: false).selectedConversation.length == 32) {
|
||||
if (Provider.of<ContactInfoState>(context, listen: false).isGroup) {
|
||||
return MultiProvider(
|
||||
providers: [ChangeNotifierProvider.value(value: Provider.of<ContactInfoState>(context))],
|
||||
child: PeerSettingsView(),
|
||||
child: GroupSettingsView(),
|
||||
);
|
||||
} else {
|
||||
return MultiProvider(
|
||||
|
|
Loading…
Reference in New Issue