Skip to content

Commit

Permalink
feat(yt): add/edit/delete comments & replies
Browse files Browse the repository at this point in the history
ref: #227
  • Loading branch information
MSOB7YY committed Aug 27, 2024
1 parent 38ee6ac commit 30521bf
Show file tree
Hide file tree
Showing 12 changed files with 676 additions and 123 deletions.
2 changes: 1 addition & 1 deletion lib/base/yt_video_like_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class YtVideoLikeManager {
NamidaButton(
text: lang.REMOVE.toUpperCase(),
onPressed: () async {
NamidaNavigator.inst.closeDialog();
confirmed = true;
NamidaNavigator.inst.closeDialog();
},
),
],
Expand Down
154 changes: 94 additions & 60 deletions lib/core/functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:history_manager/history_manager.dart';
import 'package:namico_subscription_manager/core/enum.dart';
import 'package:playlist_manager/module/playlist_id.dart';
import 'package:youtipie/class/execute_details.dart';
import 'package:youtipie/core/extensions.dart' show ThumbnailPickerExt;

import 'package:namida/class/folder.dart';
import 'package:namida/class/queue.dart';
Expand Down Expand Up @@ -47,6 +48,7 @@ import 'package:namida/youtube/controller/youtube_account_controller.dart';
import 'package:namida/youtube/controller/youtube_history_controller.dart';
import 'package:namida/youtube/controller/youtube_info_controller.dart';
import 'package:namida/youtube/controller/yt_generators_controller.dart';
import 'package:namida/youtube/widgets/yt_thumbnail.dart';

class NamidaOnTaps {
static NamidaOnTaps get inst => _instance;
Expand Down Expand Up @@ -712,6 +714,7 @@ Future<String?> showNamidaBottomSheetWithTextField({
bool useRootNavigator = true,
bool showDragHandle = true,
required String title,
String? subtitle,
required BottomSheetTextFieldConfig textfieldConfig,
List<BottomSheetTextFieldConfigWC>? extraTextfieldsConfig,
required String buttonText,
Expand All @@ -720,6 +723,7 @@ Future<String?> showNamidaBottomSheetWithTextField({
required FutureOr<bool> Function(String text) onButtonTap,
Widget Function(FormState formState)? extraItemsBuilder,
Rx<bool>? isInitiallyLoading,
bool displayAccountThumbnail = false,
}) async {
final localController = textfieldConfig is BottomSheetTextFieldConfigWC ? textfieldConfig.controller : TextEditingController(text: textfieldConfig.initalControllerText);
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
Expand All @@ -743,69 +747,99 @@ Future<String?> showNamidaBottomSheetWithTextField({
child: Form(
key: formKey,
child: NamidaLoadingSwitcher(
builder: (loadingController) => Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
title,
style: context.textTheme.displayLarge,
),
const SizedBox(height: 18.0),
CustomTagTextField(
focusNode: focusNode,
controller: localController,
hintText: textfieldConfig.hintText,
labelText: textfieldConfig.labelText,
validator: textfieldConfig.validator,
maxLength: textfieldConfig.maxLength,
),
...?extraTextfieldsConfig?.map(
(e) {
return CustomTagTextField(
controller: e.controller,
hintText: e.hintText,
labelText: e.labelText,
validator: e.validator,
maxLength: e.maxLength,
);
},
),
if (extraItemsBuilder != null) extraItemsBuilder(formKey.currentState!),
const SizedBox(height: 18.0),
Row(
children: [
SizedBox(width: context.width * 0.1),
CancelButton(onPressed: context.safePop),
SizedBox(width: context.width * 0.1),
Expanded(
child: NamidaInkWell(
borderRadius: 12.0,
padding: const EdgeInsets.all(12.0),
height: 48.0,
bgColor: buttonColor ?? CurrentColor.inst.color,
decoration: const BoxDecoration(),
child: Center(
child: Text(
buttonText,
style: buttonTextStyle ?? context.textTheme.displayMedium?.copyWith(color: Colors.white.withOpacity(0.9)),
),
builder: (loadingController) => SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
title,
style: context.textTheme.displayLarge,
),
if (subtitle != null)
Text(
subtitle,
style: context.textTheme.displaySmall,
),
if (subtitle != null) const SizedBox(height: 6.0),
const SizedBox(height: 18.0),
Row(
children: [
if (displayAccountThumbnail)
ObxO(
rx: YoutubeAccountController.current.activeAccountChannel,
builder: (context, acc) => acc == null
? const SizedBox()
: YoutubeThumbnail(
type: ThumbnailType.channel,
key: Key(acc.id),
width: 32.0,
forceSquared: false,
isImportantInCache: true,
customUrl: acc.thumbnails.pick()?.url,
isCircle: true,
),
),
onTap: () async {
if (formKey.currentState!.validate()) {
loadingController.startLoading();
final didAgree = await onButtonTap(localController.text);
loadingController.stopLoading();
if (didAgree) {
finalText = localController.text;
if (context.mounted) context.safePop();
if (displayAccountThumbnail) const SizedBox(width: 12.0),
Expanded(
child: CustomTagTextField(
focusNode: focusNode,
controller: localController,
hintText: textfieldConfig.hintText,
labelText: textfieldConfig.labelText,
validator: textfieldConfig.validator,
maxLength: textfieldConfig.maxLength,
),
),
],
),
...?extraTextfieldsConfig?.map(
(e) {
return CustomTagTextField(
controller: e.controller,
hintText: e.hintText,
labelText: e.labelText,
validator: e.validator,
maxLength: e.maxLength,
);
},
),
if (extraItemsBuilder != null) extraItemsBuilder(formKey.currentState!),
const SizedBox(height: 18.0),
Row(
children: [
SizedBox(width: context.width * 0.1),
CancelButton(onPressed: context.safePop),
SizedBox(width: context.width * 0.1),
Expanded(
child: NamidaInkWell(
borderRadius: 12.0,
padding: const EdgeInsets.all(12.0),
height: 48.0,
bgColor: buttonColor ?? CurrentColor.inst.color,
decoration: const BoxDecoration(),
child: Center(
child: Text(
buttonText,
style: buttonTextStyle ?? context.textTheme.displayMedium?.copyWith(color: Colors.white.withOpacity(0.9)),
),
),
onTap: () async {
if (formKey.currentState!.validate()) {
loadingController.startLoading();
final didAgree = await onButtonTap(localController.text);
loadingController.stopLoading();
if (didAgree) {
finalText = localController.text;
if (context.mounted) context.safePop();
}
}
}
},
},
),
),
),
],
),
],
],
),
],
),
),
),
),
Expand Down
1 change: 1 addition & 0 deletions lib/core/translations/keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ abstract class LanguageKeys {
String get REPEAT_MODE_NONE => _getKey('REPEAT_MODE_NONE');
String get REPEAT_MODE_ONE => _getKey('REPEAT_MODE_ONE');
String get REPLIES => _getKey('REPLIES');
String get REPLY => _getKey('REPLY');
String get REQUIRES_CLEARING_IMAGE_CACHE_AND_RE_INDEXING => _getKey('REQUIRES_CLEARING_IMAGE_CACHE_AND_RE_INDEXING');
String get RESCAN_VIDEOS => _getKey('RESCAN_VIDEOS');
String get RESET_BRIGHTNESS => _getKey('RESET_BRIGHTNESS');
Expand Down
7 changes: 4 additions & 3 deletions lib/ui/widgets/custom_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2917,9 +2917,9 @@ class NamidaInkWellButton extends StatelessWidget {
size: 18.0 * sizeMultiplier,
color: itemsColor,
),
SizedBox(width: 6.0 * sizeMultiplier),
],
if (textGood)
if (textGood) ...[
SizedBox(width: 6.0 * sizeMultiplier),
Flexible(
child: Text(
text,
Expand All @@ -2929,7 +2929,8 @@ class NamidaInkWellButton extends StatelessWidget {
),
),
),
if (textGood) const SizedBox(width: 4.0),
if (textGood) const SizedBox(width: 4.0),
],
if (trailing != null) trailing!,
],
),
Expand Down
2 changes: 1 addition & 1 deletion lib/youtube/functions/add_to_playlist_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ class __PlaylistsForVideoPageState extends State<_PlaylistsForVideoPage> {
NamidaButton(
text: lang.REMOVE.toUpperCase(),
onPressed: () async {
NamidaNavigator.inst.closeDialog();
confirmed = true;
NamidaNavigator.inst.closeDialog();
},
),
],
Expand Down
Loading

0 comments on commit 30521bf

Please sign in to comment.