remove mysterious auto generated files
This commit is contained in:
parent
f6fd580a6d
commit
a7e1dbc85f
4 changed files with 0 additions and 500 deletions
|
|
@ -1,168 +0,0 @@
|
|||
import 'dart:async';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/choreographer.dart';
|
||||
import 'package:fluffychat/pangea/constants/colors.dart';
|
||||
import 'package:fluffychat/pangea/controllers/subscription_controller.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
import '../../../pages/chat/chat.dart';
|
||||
|
||||
class StartIGCButton extends StatefulWidget {
|
||||
const StartIGCButton({
|
||||
super.key,
|
||||
required this.controller,
|
||||
});
|
||||
|
||||
final ChatController controller;
|
||||
|
||||
@override
|
||||
State<StartIGCButton> createState() => StartIGCButtonState();
|
||||
}
|
||||
|
||||
class StartIGCButtonState extends State<StartIGCButton>
|
||||
with SingleTickerProviderStateMixin {
|
||||
AssistanceState get assistanceState =>
|
||||
widget.controller.choreographer.assistanceState;
|
||||
AnimationController? _controller;
|
||||
StreamSubscription? choreoListener;
|
||||
AssistanceState? prevState;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(seconds: 2),
|
||||
);
|
||||
choreoListener = widget.controller.choreographer.stateListener.stream
|
||||
.listen(updateSpinnerState);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
void updateSpinnerState(_) {
|
||||
if (prevState != AssistanceState.fetching &&
|
||||
assistanceState == AssistanceState.fetching) {
|
||||
_controller?.repeat();
|
||||
} else if (prevState == AssistanceState.fetching &&
|
||||
assistanceState != AssistanceState.fetching) {
|
||||
_controller?.stop();
|
||||
_controller?.reverse();
|
||||
}
|
||||
setState(() => prevState = assistanceState);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bool itEnabled = widget.controller.choreographer.itEnabled;
|
||||
final bool igcEnabled = widget.controller.choreographer.igcEnabled;
|
||||
final CanSendStatus canSendStatus =
|
||||
widget.controller.pangeaController.subscriptionController.canSendStatus;
|
||||
final bool grammarCorrectionEnabled =
|
||||
(itEnabled || igcEnabled) && canSendStatus == CanSendStatus.subscribed;
|
||||
|
||||
if (!grammarCorrectionEnabled ||
|
||||
widget.controller.choreographer.isAutoIGCEnabled ||
|
||||
widget.controller.choreographer.choreoMode == ChoreoMode.it) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
final Widget icon = Icon(
|
||||
Icons.autorenew_rounded,
|
||||
size: 46,
|
||||
color: assistanceState.stateColor(context),
|
||||
);
|
||||
|
||||
return SizedBox(
|
||||
height: 50,
|
||||
width: 50,
|
||||
child: FloatingActionButton(
|
||||
tooltip: assistanceState.tooltip(
|
||||
L10n.of(context)!,
|
||||
),
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
disabledElevation: 0,
|
||||
shape: const CircleBorder(),
|
||||
onPressed: () {
|
||||
if (assistanceState != AssistanceState.complete) {
|
||||
widget.controller.choreographer
|
||||
.getLanguageHelp(
|
||||
false,
|
||||
true,
|
||||
)
|
||||
.then((_) {
|
||||
if (widget.controller.choreographer.igc.igcTextData != null &&
|
||||
widget.controller.choreographer.igc.igcTextData!.matches
|
||||
.isNotEmpty) {
|
||||
widget.controller.choreographer.igc.showFirstMatch(context);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
_controller != null
|
||||
? RotationTransition(
|
||||
turns: Tween(begin: 0.0, end: math.pi * 2)
|
||||
.animate(_controller!),
|
||||
child: icon,
|
||||
)
|
||||
: icon,
|
||||
Container(
|
||||
width: 26,
|
||||
height: 26,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 20,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: assistanceState.stateColor(context),
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
size: 16,
|
||||
Icons.check,
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension AssistanceStateExtension on AssistanceState {
|
||||
Color stateColor(context) {
|
||||
switch (this) {
|
||||
case AssistanceState.noMessage:
|
||||
case AssistanceState.notFetched:
|
||||
case AssistanceState.fetching:
|
||||
return Theme.of(context).colorScheme.primary;
|
||||
case AssistanceState.fetched:
|
||||
return PangeaColors.igcError;
|
||||
case AssistanceState.complete:
|
||||
return AppConfig.success;
|
||||
}
|
||||
}
|
||||
|
||||
String tooltip(L10n l10n) {
|
||||
switch (this) {
|
||||
case AssistanceState.noMessage:
|
||||
case AssistanceState.notFetched:
|
||||
return l10n.runGrammarCorrection;
|
||||
case AssistanceState.fetching:
|
||||
return "";
|
||||
case AssistanceState.fetched:
|
||||
return l10n.grammarCorrectionFailed;
|
||||
case AssistanceState.complete:
|
||||
return l10n.grammarCorrectionComplete;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:fluffychat/pangea/choreographer/controllers/choreographer.dart';
|
||||
import 'package:fluffychat/pangea/models/span_data.dart';
|
||||
import 'package:fluffychat/pangea/repo/span_data_repo.dart';
|
||||
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class _SpanDetailsCacheItem {
|
||||
Future<SpanDetailsRepoReqAndRes> data;
|
||||
|
||||
_SpanDetailsCacheItem({required this.data});
|
||||
}
|
||||
|
||||
class SpanDataController {
|
||||
late Choreographer choreographer;
|
||||
final Map<int, _SpanDetailsCacheItem> _cache = {};
|
||||
Timer? _cacheClearTimer;
|
||||
|
||||
SpanDataController(this.choreographer) {
|
||||
_initializeCacheClearing();
|
||||
}
|
||||
|
||||
void _initializeCacheClearing() {
|
||||
const duration = Duration(minutes: 2);
|
||||
_cacheClearTimer = Timer.periodic(duration, (Timer t) => clearCache());
|
||||
}
|
||||
|
||||
void clearCache() {
|
||||
_cache.clear();
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
_cacheClearTimer?.cancel();
|
||||
}
|
||||
|
||||
Future<void> getSpanDetails(int matchIndex) async {
|
||||
if (choreographer.igc.igcTextData == null ||
|
||||
choreographer.igc.igcTextData!.matches.isEmpty ||
|
||||
matchIndex < 0 ||
|
||||
matchIndex >= choreographer.igc.igcTextData!.matches.length) {
|
||||
debugger(when: kDebugMode);
|
||||
return;
|
||||
}
|
||||
|
||||
/// Retrieves the span data from the `igcTextData` matches at the specified `matchIndex`.
|
||||
/// Creates a `SpanDetailsRepoReqAndRes` object with the retrieved span data and other parameters.
|
||||
/// Generates a cache key based on the created `SpanDetailsRepoReqAndRes` object.
|
||||
final SpanData span =
|
||||
choreographer.igc.igcTextData!.matches[matchIndex].match;
|
||||
final req = SpanDetailsRepoReqAndRes(
|
||||
userL1: choreographer.l1LangCode!,
|
||||
userL2: choreographer.l2LangCode!,
|
||||
enableIGC: choreographer.igcEnabled,
|
||||
enableIT: choreographer.itEnabled,
|
||||
span: span,
|
||||
);
|
||||
final int cacheKey = req.hashCode;
|
||||
|
||||
/// Retrieves the [SpanDetailsRepoReqAndRes] response from the cache if it exists,
|
||||
/// otherwise makes an API call to get the response and stores it in the cache.
|
||||
Future<SpanDetailsRepoReqAndRes> response;
|
||||
if (_cache.containsKey(cacheKey)) {
|
||||
response = _cache[cacheKey]!.data;
|
||||
} else {
|
||||
response = SpanDataRepo.getSpanDetails(
|
||||
await choreographer.accessToken,
|
||||
request: SpanDetailsRepoReqAndRes(
|
||||
userL1: choreographer.l1LangCode!,
|
||||
userL2: choreographer.l2LangCode!,
|
||||
enableIGC: choreographer.igcEnabled,
|
||||
enableIT: choreographer.itEnabled,
|
||||
span: span,
|
||||
),
|
||||
);
|
||||
_cache[cacheKey] = _SpanDetailsCacheItem(data: response);
|
||||
}
|
||||
|
||||
try {
|
||||
choreographer.igc.igcTextData!.matches[matchIndex].match =
|
||||
(await response).span;
|
||||
} catch (err, s) {
|
||||
ErrorHandler.logError(e: err, s: s);
|
||||
}
|
||||
|
||||
choreographer.setState();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,157 +0,0 @@
|
|||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:fluffychat/pages/chat_details/chat_details.dart';
|
||||
import 'package:fluffychat/pangea/extensions/pangea_room_extension/pangea_room_extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
class RoomCapacityButton extends StatefulWidget {
|
||||
final Room? room;
|
||||
final ChatDetailsController? controller;
|
||||
const RoomCapacityButton({
|
||||
super.key,
|
||||
this.room,
|
||||
this.controller,
|
||||
});
|
||||
|
||||
@override
|
||||
RoomCapacityButtonState createState() => RoomCapacityButtonState();
|
||||
}
|
||||
|
||||
class RoomCapacityButtonState extends State<RoomCapacityButton> {
|
||||
int? capacity;
|
||||
String? nonAdmins;
|
||||
|
||||
RoomCapacityButtonState({Key? key});
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
capacity = widget.room?.capacity;
|
||||
widget.room?.numNonAdmins.then(
|
||||
(value) => setState(() {
|
||||
nonAdmins = value.toString();
|
||||
overCapacity();
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(RoomCapacityButton oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.room != widget.room) {
|
||||
capacity = widget.room?.capacity;
|
||||
widget.room?.numNonAdmins.then(
|
||||
(value) => setState(() {
|
||||
nonAdmins = value.toString();
|
||||
overCapacity();
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> overCapacity() async {
|
||||
if ((widget.room?.isRoomAdmin ?? false) &&
|
||||
capacity != null &&
|
||||
nonAdmins != null &&
|
||||
int.parse(nonAdmins!) > capacity!) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
L10n.of(context)!.roomExceedsCapacity,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final iconColor = Theme.of(context).textTheme.bodyLarge!.color;
|
||||
return Column(
|
||||
children: [
|
||||
ListTile(
|
||||
onTap: (widget.room?.isRoomAdmin ?? true) ? setRoomCapacity : null,
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
foregroundColor: iconColor,
|
||||
child: const Icon(Icons.reduce_capacity),
|
||||
),
|
||||
subtitle: Text(
|
||||
(capacity == null)
|
||||
? L10n.of(context)!.capacityNotSet
|
||||
: (nonAdmins != null)
|
||||
? '$nonAdmins/$capacity'
|
||||
: '$capacity',
|
||||
),
|
||||
title: Text(
|
||||
L10n.of(context)!.roomCapacity,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> setCapacity(int newCapacity) async {
|
||||
capacity = newCapacity;
|
||||
}
|
||||
|
||||
Future<void> setRoomCapacity() async {
|
||||
final input = await showTextInputDialog(
|
||||
context: context,
|
||||
title: L10n.of(context)!.roomCapacity,
|
||||
message: L10n.of(context)!.roomCapacityExplanation,
|
||||
okLabel: L10n.of(context)!.ok,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
textFields: [
|
||||
DialogTextField(
|
||||
initialText: ((capacity != null) ? '$capacity' : ''),
|
||||
keyboardType: TextInputType.number,
|
||||
maxLength: 3,
|
||||
validator: (value) {
|
||||
if (value == null ||
|
||||
value.isEmpty ||
|
||||
int.tryParse(value) == null ||
|
||||
int.parse(value) < 0) {
|
||||
return L10n.of(context)!.enterNumber;
|
||||
}
|
||||
if (nonAdmins != null && int.parse(value) < int.parse(nonAdmins!)) {
|
||||
return L10n.of(context)!.capacitySetTooLow;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
if (input == null ||
|
||||
input.first == "" ||
|
||||
int.tryParse(input.first) == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final newCapacity = int.parse(input.first);
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => ((widget.room != null)
|
||||
? (widget.room!.updateRoomCapacity(
|
||||
capacity = newCapacity,
|
||||
))
|
||||
: setCapacity(newCapacity)),
|
||||
);
|
||||
if (success.error == null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
L10n.of(context)!.roomCapacityHasBeenChanged,
|
||||
),
|
||||
),
|
||||
);
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_webrtc/flutter_webrtc.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
class VideoRenderer extends StatefulWidget {
|
||||
final WrappedMediaStream? stream;
|
||||
final bool mirror;
|
||||
final RTCVideoViewObjectFit fit;
|
||||
|
||||
const VideoRenderer(
|
||||
this.stream, {
|
||||
this.mirror = false,
|
||||
this.fit = RTCVideoViewObjectFit.RTCVideoViewObjectFitContain,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _VideoRendererState();
|
||||
}
|
||||
|
||||
class _VideoRendererState extends State<VideoRenderer> {
|
||||
RTCVideoRenderer? _renderer;
|
||||
bool _rendererReady = false;
|
||||
MediaStream? get mediaStream => widget.stream?.stream;
|
||||
StreamSubscription? _streamChangeSubscription;
|
||||
|
||||
Future<RTCVideoRenderer> _initializeRenderer() async {
|
||||
_renderer ??= RTCVideoRenderer();
|
||||
await _renderer!.initialize();
|
||||
_renderer!.srcObject = mediaStream;
|
||||
return _renderer!;
|
||||
}
|
||||
|
||||
void disposeRenderer() {
|
||||
try {
|
||||
_renderer?.srcObject = null;
|
||||
_renderer?.dispose();
|
||||
_renderer = null;
|
||||
// ignore: empty_catches
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_streamChangeSubscription =
|
||||
widget.stream?.onStreamChanged.stream.listen((stream) {
|
||||
setState(() {
|
||||
_renderer?.srcObject = stream;
|
||||
});
|
||||
});
|
||||
setupRenderer();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Future<void> setupRenderer() async {
|
||||
await _initializeRenderer();
|
||||
setState(() => _rendererReady = true);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_streamChangeSubscription?.cancel();
|
||||
disposeRenderer();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => !_rendererReady
|
||||
? Container()
|
||||
: Builder(
|
||||
key: widget.key,
|
||||
builder: (ctx) {
|
||||
return RTCVideoView(
|
||||
_renderer!,
|
||||
mirror: widget.mirror,
|
||||
filterQuality: FilterQuality.medium,
|
||||
objectFit: widget.fit,
|
||||
placeholderBuilder: (_) =>
|
||||
Container(color: Colors.white.withOpacity(0.18)),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue