Skip to content

Commit

Permalink
Merge pull request #37 from daoxve/dev
Browse files Browse the repository at this point in the history
Add export range functionality
  • Loading branch information
KyleKun authored Dec 21, 2022
2 parents e07943d + 001209b commit 9d3452b
Show file tree
Hide file tree
Showing 18 changed files with 529 additions and 12 deletions.
16 changes: 16 additions & 0 deletions lib/enums/export_date_range.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
enum ExportDateRange {
allTime('All Time', 'allTime'),
last7Days('Last 7 days', 'last7Days'),
last30Days('Last 30 days', 'last30Days'),
last60Days('Last 60 days', 'last60Days'),
last90Days('Last 90 days', 'last90Days'),
thisMonth('This month', 'thisMonth'),
thisYear('This year', 'thisYear'),
lastYear('Last year', 'lastYear'),
custom('Custom', 'custom');

final String label;
final String localizationLabel;

const ExportDateRange(this.label, this.localizationLabel);
}
11 changes: 11 additions & 0 deletions lib/lang/de.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,15 @@ const Map<String, String> de = {
'ok': 'OK',
'reset': 'Zurücksetzen',
'enterLocation': 'Ort eingeben',
'allTime': 'Alle zeit',
'last7Days': 'Letzten 7 tage',
'last30Days': 'Letzte 30 tage',
'last60Days':'Letzte 60 tage',
'last90Days':'Letzte 90 tage',
'thisMonth': 'Diesen monat',
'thisYear': 'Dieses jahr',
'lastYear': 'Letztes jahr',
'custom': 'Brauch',
'dateRange': 'Datumsbereich',
'clipsFound': 'Clips gefunden',
};
11 changes: 11 additions & 0 deletions lib/lang/en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,15 @@ const Map<String, String> en = {
'ok': 'OK',
'reset': 'Reset',
'enterLocation': 'Enter location',
'allTime': 'All Time',
'last7Days': 'Last 7 days',
'last30Days': 'Last 30 days',
'last60Days':'Last 60 days',
'last90Days':'Last 90 days',
'thisMonth': 'This month',
'thisYear': 'This year',
'lastYear': 'Last year',
'custom': 'Custom',
'dateRange': 'Date Range',
'clipsFound': 'Clips Found',
};
11 changes: 11 additions & 0 deletions lib/lang/es.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,15 @@ const Map<String, String> es = {
'ok': 'OK',
'reset': 'Reiniciar',
'enterLocation': 'Ingrese la ubicación',
'allTime': 'Todo el tiempo',
'last7Days': 'Los últimos 7 días',
'last30Days': 'Últimos 30 días',
'last60Days':'Últimos 60 días',
'last90Days':'Últimos 90 días',
'thisMonth': 'Este mes',
'thisYear': 'Este año',
'lastYear': 'El año pasado',
'custom': 'Disfraz',
'dateRange': 'Rango de fechas',
'clipsFound': 'Clips encontrados',
};
11 changes: 11 additions & 0 deletions lib/lang/fr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,15 @@ const Map<String, String> fr = {
'ok': 'D\'accord',
'reset': 'Réinitialiser',
'enterLocation': 'Entrer l\'emplacement',
'allTime': 'Tout le temps',
'last7Days': 'Les 7 derniers jours',
'last30Days': 'Les 30 derniers jours',
'last60Days':'60 derniers jours',
'last90Days':'90 derniers jours',
'thisMonth': 'Ce mois-ci',
'thisYear': 'Cette année',
'lastYear': 'L\'année dernière',
'custom': 'Personnalisé',
'dateRange': 'Date Range',
'clipsFound': 'Clips trouvés',
};
11 changes: 11 additions & 0 deletions lib/lang/id.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,15 @@ const Map<String, String> id = {
'ok': 'Oke',
'reset': 'Mengatur ulang',
'enterLocation': 'Masukkan lokasi',
'allTime': 'Sepanjang waktu',
'last7Days': '7 hari terakhir',
'last30Days': '30 hari terakhir',
'last60Days':'60 hari terakhir',
'last90Days':'90 hari terakhir',
'thisMonth': 'Bulan ini',
'thisYear': 'Tahun ini',
'lastYear': 'Tahun lalu',
'custom': 'Kebiasaan',
'dateRange': 'Rentang tanggal',
'clipsFound': 'Klip ditemukan',
};
11 changes: 11 additions & 0 deletions lib/lang/pt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,15 @@ const Map<String, String> pt = {
'ok': 'OK',
'reset': 'Redefinir',
'enterLocation': 'Digite o local',
'allTime': 'Tempo todo',
'last7Days': 'Últimos 7 dias',
'last30Days': 'Últimos 30 dias',
'last60Days':'Últimos 60 dias',
'last90Days':'Últimos 90 dias',
'thisMonth': 'Este mês',
'thisYear': 'Este ano',
'lastYear': 'Ano passado',
'custom': 'Personalizada',
'dateRange': 'DATA DE DATA',
'clipsFound': 'Clipes encontrados',
};
11 changes: 11 additions & 0 deletions lib/lang/zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,15 @@ const Map<String, String> zh = {
'ok': '好的',
'reset': '重置',
'enterLocation': '输入位置',
'allTime': '整天',
'last7Days': '最近7天',
'last30Days': '最近30天',
'last60Days':'最近60天',
'last90Days':'最近90天',
'thisMonth': '这个月',
'thisYear': '今年',
'lastYear': '去年',
'custom': '风俗',
'dateRange': '日期范围',
'clipsFound': '找到夹子',
};
34 changes: 32 additions & 2 deletions lib/pages/home/create_movie/create_movie_screen.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'widgets/create_movie_button.dart';
import '../../../routes/app_pages.dart';
import '../../../utils/constants.dart';
import 'widgets/video_count_card.dart';

class CreateMoviePage extends StatelessWidget {
Expand All @@ -23,9 +24,38 @@ class CreateMoviePage extends StatelessWidget {
style: TextStyle(fontSize: MediaQuery.of(context).size.width * 0.045),
textAlign: TextAlign.center,
),
CreateMovieButton(),
const _CreateMovieOptionsButton(),
const SizedBox(),
],
);
}
}

class _CreateMovieOptionsButton extends StatelessWidget {
const _CreateMovieOptionsButton();

@override
Widget build(BuildContext context) {
return SizedBox(
width: MediaQuery.of(context).size.width * 0.4,
height: MediaQuery.of(context).size.height * 0.08,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: AppColors.mainColor,
elevation: 5.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(80.0),
),
),
onPressed: () async => await Get.toNamed(Routes.CREATEMOVIEOPTIONS),
child: Text(
'create'.tr,
style: TextStyle(
color: Colors.white,
fontSize: MediaQuery.of(context).size.width * 0.055,
),
),
),
);
}
}
30 changes: 26 additions & 4 deletions lib/pages/home/create_movie/widgets/create_movie_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'package:get/get.dart';
import 'package:open_file/open_file.dart';

import '../../../../controllers/video_count_controller.dart';
import '../../../../enums/export_date_range.dart';
// import '../../../../enums/export_orientations.dart';
import '../../../../utils/constants.dart';
import '../../../../utils/custom_dialog.dart';
import '../../../../utils/date_format_utils.dart';
Expand All @@ -13,6 +15,17 @@ import '../../../../utils/storage_utils.dart';
import '../../../../utils/utils.dart';

class CreateMovieButton extends StatefulWidget {
const CreateMovieButton({
super.key,
required this.selectedExportDateRange,
// required this.selectedOrientation,
required this.customSelectedVideos,
});

final ExportDateRange selectedExportDateRange;
// final ExportOrientation selectedOrientation;
final List<String> customSelectedVideos;

@override
_CreateMovieButtonState createState() => _CreateMovieButtonState();
}
Expand All @@ -34,10 +47,18 @@ class _CreateMovieButtonState extends State<CreateMovieButton> {
isProcessing = true;
});
try {
final allVideos = Utils.getAllVideosFromStorage();
final selectedExportDateRange = widget.selectedExportDateRange;
final customSelectedVideos = widget.customSelectedVideos;
List<String> selectedVideos = [];

if (customSelectedVideos.isNotEmpty) {
selectedVideos = customSelectedVideos;
} else {
selectedVideos = Utils.getSelectedVideosFromStorage(selectedExportDateRange);
}

// Needs more than 1 video to create movie
if (allVideos.length < 2) {
if (selectedVideos.length < 2) {
showDialog(
barrierDismissible: false,
context: Get.context!,
Expand All @@ -55,13 +76,14 @@ class _CreateMovieButtonState extends State<CreateMovieButton> {
final String today = DateFormatUtils.getToday();

// Creating txt that will be used with ffmpeg
final String txtPath = await Utils.writeTxt(allVideos);
final String txtPath = await Utils.writeTxt(selectedVideos);
// Utils().logInfo('Saved txt');
final String outputPath =
'${SharedPrefsUtil.getString('moviesPath')}OneSecondDiary-Movie-${_movieCount.movieCount.value}-$today.mp4';
// Utils().logInfo('It will be saved in: $outputPath');

await executeFFmpeg('-f concat -safe 0 -i $txtPath -map 0 -c copy $outputPath -y').then(
await executeFFmpeg('-f concat -safe 0 -i $txtPath -map 0 -c copy $outputPath -y')
.then(
(session) async {
final returnCode = await session.getReturnCode();
if (ReturnCode.isSuccess(returnCode)) {
Expand Down
Loading

0 comments on commit 9d3452b

Please sign in to comment.