Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calendar UI tweaks #46

Merged
merged 4 commits into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/lang/pt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const Map<String, String> pt = {
'ok': 'OK',
'reset': 'Redefinir',
'enterLocation': 'Digite o local',
'allTime': 'Tempo todo',
'allTime': 'Tudo',
'last7Days': 'Últimos 7 dias',
'last30Days': 'Últimos 30 dias',
'last60Days': 'Últimos 60 dias',
Expand Down
51 changes: 27 additions & 24 deletions lib/pages/home/calendar_editor/calendar_editor_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:get/get.dart';
import 'package:path_provider/path_provider.dart';
import 'package:video_thumbnail/video_thumbnail.dart';

import '../../../controllers/lang_controller.dart';
import '../../../utils/constants.dart';
import '../../../utils/date_format_utils.dart';
import '../../../utils/ffmpeg_api_wrapper.dart';
Expand All @@ -32,6 +33,7 @@ class _CalendarEditorPageState extends State<CalendarEditorPage> {
DateTime _currentDate = DateTime.now();
late Color mainColor;
final String _currentDateStr = DateFormatUtils.getToday(isDayFirst: false);
final LanguageController _languageController = Get.find();

@override
void initState() {
Expand Down Expand Up @@ -74,7 +76,7 @@ class _CalendarEditorPageState extends State<CalendarEditorPage> {
Container(
margin: const EdgeInsets.symmetric(horizontal: 16.0),
child: CalendarCarousel<Event>(
childAspectRatio: 1.05,
childAspectRatio: 1.2,
onDayPressed: (DateTime date, List<Event> events) {
setState(
() => _currentDate = date,
Expand Down Expand Up @@ -133,7 +135,7 @@ class _CalendarEditorPageState extends State<CalendarEditorPage> {
child: Text(
date.day.toString(),
style: TextStyle(
color: hasVideo ? Colors.green : Colors.red,
color: hasVideo ? AppColors.green : AppColors.mainColor,
fontFamily: 'Magic',
),
),
Expand All @@ -158,26 +160,22 @@ class _CalendarEditorPageState extends State<CalendarEditorPage> {
inactiveDaysTextStyle: const TextStyle(
fontFamily: 'Magic',
),
nextDaysTextStyle: const TextStyle(
color: Colors.grey,
fontFamily: 'Magic',
),
prevDaysTextStyle: const TextStyle(
color: Colors.grey,
fontFamily: 'Magic',
),
weekdayTextStyle: TextStyle(
fontFamily: 'Magic',
color: mainColor,
fontWeight: FontWeight.w900,
),
weekFormat: false,
iconColor:
ThemeService().isDarkTheme() ? Colors.white : Colors.black, // Color of icon
ThemeService().isDarkTheme() ? Colors.white : Colors.black,
headerTextStyle: TextStyle(
fontFamily: 'Magic',
fontSize: 20.0,
color: mainColor,
),
locale: _languageController.selectedLanguage.value,
shouldShowTransform: false,
showOnlyCurrentMonthDate: true,
height: 350.0,
selectedDateTime: _currentDate,
daysHaveCircularBorder: true,
Expand All @@ -202,7 +200,8 @@ class _CalendarEditorPageState extends State<CalendarEditorPage> {
child: FutureBuilder(
future: getThumbnail(currentVideo),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
return Center(
child: SizedBox(
height: 30,
Expand Down Expand Up @@ -230,13 +229,14 @@ class _CalendarEditorPageState extends State<CalendarEditorPage> {
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: AppColors.mainColor,
backgroundColor: AppColors.purple,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
),
onPressed: () async {
final Directory directory = await getApplicationDocumentsDirectory();
final Directory directory =
await getApplicationDocumentsDirectory();
final String srtPath = '${directory.path}/temp.srt';
final getSubsFile =
await executeFFmpeg('-i $currentVideo $srtPath -y');
Expand All @@ -261,9 +261,12 @@ class _CalendarEditorPageState extends State<CalendarEditorPage> {
),
);
},
child: Text(
'editSubtitles'.tr,
textAlign: TextAlign.center,
child: Padding(
padding: const EdgeInsets.all(4.0),
child: Text(
'editSubtitles'.tr,
textAlign: TextAlign.center,
),
),
),
),
Expand All @@ -273,9 +276,6 @@ class _CalendarEditorPageState extends State<CalendarEditorPage> {
} else ...{
Column(
children: [
const SizedBox(
height: 20.0,
),
Text('noVideoRecorded'.tr),
const SizedBox(
height: 10.0,
Expand All @@ -284,16 +284,19 @@ class _CalendarEditorPageState extends State<CalendarEditorPage> {
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: AppColors.yellow,
backgroundColor: AppColors.mainColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
),
// TODO: implement
onPressed: () {},
child: Text(
'addVideo'.tr,
textAlign: TextAlign.center,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'addVideo'.tr,
textAlign: TextAlign.center,
),
),
),
),
Expand Down
1 change: 1 addition & 0 deletions lib/pages/home/create_movie/create_movie_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class _CreateMovieOptionsButton extends StatelessWidget {
onPressed: () async => await Get.toNamed(Routes.CREATE_MOVIE_OPTIONS),
child: Text(
'createMovie'.tr,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: MediaQuery.of(context).size.width * 0.055,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:video_thumbnail/video_thumbnail.dart';

import '../../../../utils/date_format_utils.dart';
import '../../../../utils/lazy_future_builder.dart';
import '../../../../utils/utils.dart';
import 'create_movie_button.dart';
Expand Down Expand Up @@ -104,7 +105,9 @@ class _SelectVideoFromStorageState extends State<SelectVideoFromStorage> {
return Column(
children: [
Text(
allVideos[index].split('/').last.split('.mp4')[0],
DateFormatUtils.parseDateStringAccordingLocale(
allVideos[index].split('/').last.split('.mp4').first,
),
key: globalKeys[index],
),
GestureDetector(
Expand Down
19 changes: 16 additions & 3 deletions lib/utils/date_format_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class DateFormatUtils {
}
}

/// Get the given date and format it properly
/// Get the given date and format it properly
static String getDate(DateTime date, {bool? isDayFirst}) {
// If no default value is given, we check directly in the function
isDayFirst ??= isDayFirstPattern();
Expand All @@ -107,13 +107,26 @@ class DateFormatUtils {
}
}

static String parseDateStringAccordingLocale(String date) {
if (isDayFirstPattern()) {
final String year = date.split('-').first;
final String month = date.split('-')[1];
final String day = date.split('-').last;
return '$day-$month-$year';
}

return date;
}

/// Convert the given date from the app's ffmpeg friendly format to DateTime
static DateTime parseToDateTime(String date, {bool? isDayFirst}) {
isDayFirst ??= isDayFirstPattern();

final String day = isDayFirst ? date.split('-').first : date.split('-').last;
final String day =
isDayFirst ? date.split('-').first : date.split('-').last;
final String month = date.split('-')[1];
final String year = isDayFirst ? date.split('-').last : date.split('-').first;
final String year =
isDayFirst ? date.split('-').last : date.split('-').first;

return DateTime(year.toInt(), month.toInt(), day.toInt());
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Record one second of your day, everyday.

publish_to: "none"

version: 1.5.0+1
version: 1.5.0+8

environment:
sdk: ">=2.18.2 <3.0.0"
Expand Down