Skip to content

Commit

Permalink
Pre-release tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ketchel committed Jun 14, 2023
1 parent d021642 commit 457ced1
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 115 deletions.
250 changes: 139 additions & 111 deletions lib/views/mumble_ui/mumble_ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,121 +28,149 @@ class MumbleUiView extends StatelessWidget with UiLoggy {
// the App.build method, and use it to set our appbar title.
title: Text("RG Nets PTToC Demo"),
),
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
if (!mumbleUiVM.connected)
Card(
child: Padding(
padding: EdgeInsets.all(8),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextField(
controller: mumbleUiVM.hostTextController,
decoration: const InputDecoration(
icon: Icon(Icons.storage),
label: Text("Host")),
onEditingComplete: () =>
FocusScope.of(context).nextFocus()),
TextField(
controller: mumbleUiVM.portTextController,
keyboardType: TextInputType.number,
maxLength: 5,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly
],
decoration: const InputDecoration(
icon: Icon(Icons.lan),
label: Text("Port")),
onEditingComplete: () =>
FocusScope.of(context).nextFocus()),
TextField(
controller: mumbleUiVM.nameTextController,
decoration: const InputDecoration(
icon: Icon(Icons.person),
label: Text("Name")),
onEditingComplete: () =>
FocusScope.of(context).nextFocus()),
TextField(
controller:
mumbleUiVM.passwordTextController,
decoration: const InputDecoration(
icon: Icon(Icons.key),
label: Text("Password")),
obscureText: true,
obscuringCharacter: '*',
onEditingComplete: () =>
FocusScope.of(context).nextFocus()),
],
)),
),
if (!mumbleUiVM.connected)
TextButton(
onPressed: () {
mumbleUiVM
.connect()
.then((value) => GuiUtils()
.showTextSnackbar(context, 'Connected!'))
.onError((error, stackTrace) {
GuiUtils().showTextSnackbar(
context, "Failed to connect!",
isError: true);
print(error);
print(stackTrace);
});
body: mumbleUiVM.connected
? LayoutBuilder(builder: (context, constraints) {
var buttons = [
TextButton(
onPressed: () {
mumbleUiVM
.disconnect()
.then((value) => GuiUtils().showTextSnackbar(
context, 'Disconnected!'))
.onError((error, stackTrace) {
GuiUtils().showTextSnackbar(
context, "Failed to disconnect!",
isError: true);
// print(error);
// print(stackTrace);
});
},
child: Text("Disconnect")),
// Focus(
// autofocus: true,
// focusNode: mumbleUiVM.transmitButtonFocus,
// canRequestFocus: true,
//
// child:
InkWell(
onTapDown: (_) {
print("Start!");
mumbleUiVM.startTransmit();
},
child: Text("Connect")),
if (mumbleUiVM.connected)
TextButton(
onPressed: () {
mumbleUiVM
.disconnect()
.then((value) => GuiUtils()
.showTextSnackbar(context, 'Disconnected!'))
.onError((error, stackTrace) {
GuiUtils().showTextSnackbar(
context, "Failed to disconnect!",
isError: true);
print(error);
print(stackTrace);
});
onTapUp: (_) {
mumbleUiVM.stopTransmit();
},
child: Text("Disconnect")),
if (mumbleUiVM.connected)
// Focus(
// autofocus: true,
// focusNode: mumbleUiVM.transmitButtonFocus,
// canRequestFocus: true,
//
// child:
InkWell(
onTapDown: (_) {
print("Start!");
mumbleUiVM.startTransmit();
},
onTapUp: (_) {
mumbleUiVM.stopTransmit();
},
child: Icon(
Icons.mic,
size: 200,
color: mumbleUiVM.transmitting
? Colors.green
: Colors.red,
child: Icon(
Icons.mic,
size: 200,
color: mumbleUiVM.transmitting
? Colors.green
: Colors.red,
),
// )
),
// )
];

return Container(
constraints: BoxConstraints(
minWidth: constraints.maxWidth,
minHeight: constraints.minHeight),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: MediaQuery.of(context).orientation ==
Orientation.portrait
? buttons
: [
Row(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: buttons,
)
],
));
})
: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Card(
child: Padding(
padding: EdgeInsets.all(8),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextField(
controller:
mumbleUiVM.hostTextController,
decoration: const InputDecoration(
icon: Icon(Icons.storage),
label: Text("Host")),
onEditingComplete: () =>
FocusScope.of(context).nextFocus()),
TextField(
controller:
mumbleUiVM.portTextController,
keyboardType: TextInputType.number,
maxLength: 5,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly
],
decoration: const InputDecoration(
icon: Icon(Icons.lan),
label: Text("Port")),
onEditingComplete: () =>
FocusScope.of(context).nextFocus()),
TextField(
controller:
mumbleUiVM.nameTextController,
decoration: const InputDecoration(
icon: Icon(Icons.person),
label: Text("Name")),
onEditingComplete: () =>
FocusScope.of(context).nextFocus()),
TextField(
controller:
mumbleUiVM.passwordTextController,
decoration: const InputDecoration(
icon: Icon(Icons.key),
label: Text("Password")),
obscureText: true,
obscuringCharacter: '*',
onEditingComplete: () =>
FocusScope.of(context).nextFocus()),
],
)),
),
TextButton(
onPressed: () {
mumbleUiVM
.connect()
.then((value) => GuiUtils()
.showTextSnackbar(
context, 'Connected!'))
.onError((error, stackTrace) {
GuiUtils().showTextSnackbar(
context, "Failed to connect!",
isError: true);
print(error);
print(stackTrace);
});
},
child: Text("Connect")),
],
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
tooltip: 'Increment',
child: const Icon(Icons.add),
),
),
// floatingActionButton: FloatingActionButton(
// onPressed: () {},
// tooltip: 'Increment',
// child: const Icon(Icons.add),
// ),
);
});
});
Expand Down
6 changes: 3 additions & 3 deletions lib/views/mumble_ui/mumble_ui_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart' hide Intent;
import 'package:loggy/loggy.dart';
import 'package:pttoc_test/providers/mumble_provider.dart';
import 'package:uuid/uuid.dart';

// https://stackoverflow.com/questions/33281286/samsung-galaxy-xcover-active-button

Expand All @@ -16,12 +17,11 @@ class MumbleUiViewModel extends ChangeNotifier with UiLoggy {

FocusNode transmitButtonFocus = FocusNode();

TextEditingController hostTextController =
TextEditingController(text: "dr130.ketchel.xyz");
TextEditingController hostTextController = TextEditingController(text: "");
TextEditingController portTextController =
TextEditingController(text: "64738");
TextEditingController nameTextController =
TextEditingController(text: "Dumble Test");
TextEditingController(text: "Dumble Test (${const Uuid().v1()})");
TextEditingController passwordTextController = TextEditingController();
// Controller

Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ packages:
source: hosted
version: "1.3.2"
uuid:
dependency: transitive
dependency: "direct main"
description:
name: uuid
sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313"
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ dependencies:
permission_handler: ^10.2.0
opus_dart: ^3.0.0
audio_session: ^0.1.13
uuid: ^3.0.7

#dependency_overrides:
# ffi: "^2.0.1" # Playing with fire here, but need to do so to resolve a conflict.
Expand Down

0 comments on commit 457ced1

Please sign in to comment.