-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement local media preview * Implement local media preview * Use mixin for helper class * Use mixin for helper class * Improve progress * Improve progress * Improve app process flow * Manage video with one controller * Resolve some minor issues * Resolve some minor issues * Implement download video * Add drag down to dispose * Implement dismissible page * Show progress * Implement media transfer screen * Process Media item on background thread * Implement google drive video preview * Implement google drive video preview * Implement google drive preview * Rename func --------- Co-authored-by: cp-sneha-s <[email protected]>
- Loading branch information
1 parent
b00c0ab
commit f53be94
Showing
56 changed files
with
3,935 additions
and
594 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import 'dart:io'; | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:style/extensions/context_extensions.dart'; | ||
import 'package:style/text/app_text_style.dart'; | ||
|
||
class AppAlertAction { | ||
final String title; | ||
final bool isDestructiveAction; | ||
final VoidCallback onPressed; | ||
|
||
const AppAlertAction({ | ||
required this.title, | ||
this.isDestructiveAction = false, | ||
required this.onPressed, | ||
}); | ||
} | ||
|
||
Future<T?> showAppAlertDialog<T>({ | ||
required BuildContext context, | ||
required String title, | ||
required String message, | ||
required List<AppAlertAction> actions, | ||
}) { | ||
return showAdaptiveDialog<T>( | ||
context: context, | ||
builder: (context) { | ||
if (Platform.isIOS || Platform.isMacOS) { | ||
return CupertinoAlertDialog( | ||
title: Text(title, | ||
style: AppTextStyles.body | ||
.copyWith(color: context.colorScheme.textPrimary)), | ||
content: Text( | ||
message, | ||
style: AppTextStyles.caption | ||
.copyWith(color: context.colorScheme.textSecondary), | ||
), | ||
actions: [ | ||
for (final action in actions) | ||
CupertinoDialogAction( | ||
onPressed: action.onPressed, | ||
child: Text( | ||
action.title, | ||
style: AppTextStyles.button.copyWith( | ||
color: action.isDestructiveAction | ||
? context.colorScheme.alert | ||
: context.colorScheme.textPrimary), | ||
), | ||
), | ||
], | ||
); | ||
} | ||
|
||
return AlertDialog( | ||
backgroundColor: context.colorScheme.containerNormalOnSurface, | ||
shape: RoundedRectangleBorder( | ||
borderRadius: BorderRadius.circular(22), | ||
), | ||
title: Text(title, | ||
style: AppTextStyles.body | ||
.copyWith(color: context.colorScheme.textPrimary)), | ||
content: Text( | ||
message, | ||
style: AppTextStyles.caption | ||
.copyWith(color: context.colorScheme.textSecondary), | ||
), | ||
actions: [ | ||
for (final action in actions) | ||
TextButton( | ||
onPressed: action.onPressed, | ||
child: Text( | ||
action.title, | ||
style: AppTextStyles.button.copyWith( | ||
color: action.isDestructiveAction | ||
? context.colorScheme.alert | ||
: context.colorScheme.textPrimary), | ||
), | ||
), | ||
], | ||
); | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:style/buttons/primary_button.dart'; | ||
import 'package:style/extensions/context_extensions.dart'; | ||
import 'package:style/text/app_text_style.dart'; | ||
|
||
class ErrorViewAction { | ||
final String title; | ||
final VoidCallback onPressed; | ||
|
||
const ErrorViewAction({required this.title, required this.onPressed}); | ||
} | ||
|
||
class ErrorView extends StatelessWidget { | ||
final Widget? icon; | ||
final String title; | ||
final String message; | ||
final Color? foregroundColor; | ||
final ErrorViewAction? action; | ||
|
||
const ErrorView({ | ||
super.key, | ||
this.icon, | ||
required this.title, | ||
this.foregroundColor, | ||
this.message = '', | ||
this.action, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return SafeArea( | ||
child: Padding( | ||
padding: const EdgeInsets.all(30), | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
crossAxisAlignment: CrossAxisAlignment.center, | ||
children: [ | ||
const SizedBox(width: double.infinity), | ||
icon ?? | ||
Icon( | ||
CupertinoIcons.exclamationmark_circle, | ||
color: context.colorScheme.containerHighOnSurface, | ||
size: 100, | ||
), | ||
const SizedBox(height: 40), | ||
Text(title, | ||
style: AppTextStyles.subtitle1.copyWith( | ||
color: foregroundColor?? context.colorScheme.textPrimary, | ||
)), | ||
const SizedBox(height: 20), | ||
Text( | ||
message, | ||
style: AppTextStyles.subtitle2.copyWith( | ||
color: foregroundColor ??context.colorScheme.textSecondary, | ||
), | ||
textAlign: TextAlign.center, | ||
), | ||
if (action != null) ...[ | ||
const SizedBox(height: 20), | ||
PrimaryButton( | ||
onPressed: action!.onPressed, | ||
child: Text(action!.title, style: AppTextStyles.button,), | ||
), | ||
], | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import 'package:data/extensions/iterable_extension.dart'; | ||
import 'package:data/models/app_process/app_process.dart'; | ||
import 'package:data/models/media/media.dart'; | ||
import 'package:data/models/media/media_extension.dart'; | ||
|
||
extension MediaListExtension on List<AppMedia> { | ||
void removeGoogleDriveRefFromMedias({List<String>? removeFromIds}) { | ||
for (int index = 0; index < length; index++) { | ||
if (this[index].isGoogleDriveStored && | ||
(removeFromIds?.contains(this[index].id) ?? true)) { | ||
removeAt(index); | ||
} else if (this[index].isCommonStored && | ||
(removeFromIds?.contains(this[index].id) ?? true)) { | ||
this[index] = this[index].copyWith( | ||
sources: this[index].sources.toList() | ||
..remove(AppMediaSource.googleDrive), | ||
thumbnailLink: null, | ||
driveMediaRefId: null, | ||
); | ||
} | ||
} | ||
} | ||
|
||
void addGoogleDriveRefInMedias( | ||
{required List<AppProcess> process, List<String>? processIds}) { | ||
processIds ??= process.map((e) => e.id).toList(); | ||
updateWhere( | ||
where: (media) => processIds?.contains(media.id) ?? false, | ||
update: (media) { | ||
final res = process | ||
.where((element) => element.id == media.id) | ||
.first | ||
.response as AppMedia?; | ||
if (res == null) return media; | ||
return media.mergeGoogleDriveMedia(res); | ||
}, | ||
); | ||
} | ||
|
||
void replaceMediaRefInMedias( | ||
{required List<AppProcess> process, List<String>? processIds}) { | ||
processIds ??= process.map((e) => e.id).toList(); | ||
updateWhere( | ||
where: (media) => processIds?.contains(media.id) ?? false, | ||
update: (media) { | ||
final res = process | ||
.where((element) => element.id == media.id) | ||
.first | ||
.response as AppMedia?; | ||
|
||
if (res == null) return media; | ||
return res; | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import 'dart:math'; | ||
|
||
extension BytesFormatter on int { | ||
String get formatBytes { | ||
const List<String> suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; | ||
if (this == 0) return '0 ${suffixes[0]}'; | ||
final i = (this == 0) ? 0 : (log(this) / log(1024)).floor(); | ||
final formattedValue = (this / pow(1024, i)).toStringAsFixed(2); | ||
return '${formattedValue.endsWith('.00') ? formattedValue.substring(0, formattedValue.length - 3) : formattedValue} ${suffixes[i]}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.