Skip to content

Commit

Permalink
Merge pull request #158 from a-mabe/136-volume-control
Browse files Browse the repository at this point in the history
Volume Control, UI Update, and Bug Fixes
  • Loading branch information
a-mabe committed Aug 10, 2024
2 parents 6ecbb41 + 5fbf7a3 commit cdcd749
Show file tree
Hide file tree
Showing 11 changed files with 785 additions and 401 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.1
1.4.2
22 changes: 19 additions & 3 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
PODS:
- audio_service (0.0.1):
- Flutter
- audio_session (0.0.1):
- Flutter
- audioplayers_darwin (0.0.1):
Expand Down Expand Up @@ -51,6 +53,7 @@ PODS:
- Toast
- just_audio (0.0.1):
- Flutter
- Mute (0.6.1)
- openhiit_background_service_ios (0.0.3):
- Flutter
- package_info_plus (0.4.5):
Expand All @@ -60,6 +63,9 @@ PODS:
- FlutterMacOS
- permission_handler_apple (9.3.0):
- Flutter
- real_volume (0.0.1):
- Flutter
- Mute (~> 0.6.0)
- SDWebImage (5.19.2):
- SDWebImage/Core (= 5.19.2)
- SDWebImage/Core (5.19.2)
Expand All @@ -79,6 +85,7 @@ PODS:
- Flutter

DEPENDENCIES:
- audio_service (from `.symlinks/plugins/audio_service/ios`)
- audio_session (from `.symlinks/plugins/audio_session/ios`)
- audioplayers_darwin (from `.symlinks/plugins/audioplayers_darwin/ios`)
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
Expand All @@ -93,6 +100,7 @@ DEPENDENCIES:
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- real_volume (from `.symlinks/plugins/real_volume/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- soundpool (from `.symlinks/plugins/soundpool/ios`)
Expand All @@ -103,11 +111,14 @@ SPEC REPOS:
trunk:
- DKImagePickerController
- DKPhotoGallery
- Mute
- SDWebImage
- SwiftyGif
- Toast

EXTERNAL SOURCES:
audio_service:
:path: ".symlinks/plugins/audio_service/ios"
audio_session:
:path: ".symlinks/plugins/audio_session/ios"
audioplayers_darwin:
Expand Down Expand Up @@ -136,6 +147,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios"
real_volume:
:path: ".symlinks/plugins/real_volume/ios"
share_plus:
:path: ".symlinks/plugins/share_plus/ios"
shared_preferences_foundation:
Expand All @@ -148,7 +161,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/wakelock_plus/ios"

SPEC CHECKSUMS:
audio_session: 4f3e461722055d21515cf3261b64c973c062f345
audio_service: f509d65da41b9521a61f1c404dd58651f265a567
audio_session: 088d2483ebd1dc43f51d253d4a1c517d9a2e7207
audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40
device_info_plus: 97af1d7e84681a90d0693e63169a5d50e0839a0d
DKImagePickerController: 946cec48c7873164274ecc4624d19e3da4c1ef3c
Expand All @@ -160,13 +174,15 @@ SPEC CHECKSUMS:
flutter_local_notifications: 4cde75091f6327eb8517fa068a0a5950212d2086
fluttertoast: 723e187574b149e68e63ca4d39b837586b903cfa
just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa
Mute: 20135a96076f140cc82bfc8b810e2d6150d8ec7e
openhiit_background_service_ios: 374583024fb470f96bc23dcd35f334014f05d81e
package_info_plus: 58f0028419748fad15bf008b270aaa8e54380b1c
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
real_volume: 6d09deeabb06963275fa8df0fb1616a5886363d6
SDWebImage: dfe95b2466a9823cf9f0c6d01217c06550d7b29a
share_plus: 8875f4f2500512ea181eef553c3e27dba5135aad
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
soundpool: c7f4422ca206e77f8900ed3c4ee6a6ff5a0e38a9
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
SwiftyGif: 706c60cf65fa2bc5ee0313beece843c8eb8194d4
Expand Down
113 changes: 39 additions & 74 deletions lib/card_widgets/card_item_animated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class CardItemAnimated extends StatelessWidget {
///
final VoidCallback? onTap;

final double sizeMultiplier;

const CardItemAnimated({
super.key,
this.onTap,
Expand All @@ -36,19 +38,32 @@ class CardItemAnimated extends StatelessWidget {
required this.fontWeight,
required this.animation,
required this.item,
required this.sizeMultiplier,
});

/// Calculate padding to place around text depending on the device orientation.
///
double calcPadding(context) {
return MediaQuery.of(context).orientation == Orientation.portrait ? 15 : 5;
// return MediaQuery.of(context).orientation == Orientation.portrait ? 15 : 5;
return 10;
}

double calcHeight(String action) {
if (action.length > 20) {
if (action.length > 30) {
return 110 * sizeMultiplier;
}
return 100 * sizeMultiplier;
} else {
return 75 * sizeMultiplier;
}
}

@override
Widget build(BuildContext context) {
/// Minimum height that each ListTile can be.
///
double minHeight = 20;
double minHeight = 75;

return SlideTransition(
position: Tween<Offset>(
Expand All @@ -71,85 +86,35 @@ class CardItemAnimated extends StatelessWidget {
),
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: minHeight,
maxHeight:
MediaQuery.of(context).orientation == Orientation.portrait
? MediaQuery.of(context).size.height / 10
: MediaQuery.of(context).size.height / 8),
minHeight: minHeight,
maxHeight: calcHeight(item.action),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
// Interval number, e.g. 1/8.
Expanded(
flex: 20,
child: Padding(
padding: const EdgeInsets.fromLTRB(15, 0, 8, 0),
child: AutoSizeText(
item.intervalString().isEmpty
? ""
: item.interval.toString(),
maxLines: 1,
minFontSize: 14,
maxFontSize: 500,
style: TextStyle(
color: fontColor,
fontSize: 500,
),
))
// child: Padding(
// padding: const EdgeInsets.fromLTRB(15, 0, 12, 0),
// child: Row(
// children: [
// Expanded(
// flex: 28,
// child: Align(
// alignment: Alignment.bottomRight,
// child: AutoSizeText(
// item.intervalString().isEmpty
// ? ""
// : item.interval.toString(),
// maxLines: 1,
// minFontSize: 14,
// maxFontSize: 500,
// style: const TextStyle(
// color: Colors.white,
// fontSize: 500,
// height: 2),
// )),
// ),
// Expanded(
// flex: 2,
// child: Align(
// alignment: Alignment.bottomLeft,
// child: AutoSizeText(
// item.intervalString().isEmpty
// ? ""
// : "/${item.total}",
// maxLines: 1,
// minFontSize: 1,
// maxFontSize: 500,
// style: const TextStyle(
// color: Colors.white,
// fontSize: 500,
// height: 3),
// )
// // Padding(
// // padding: EdgeInsets.fromLTRB(0, 0, 0, 0),
// // child: AutoSizeText(
// // item.intervalString().isEmpty
// // ? ""
// // : "/${item.total}",
// // maxLines: 1,
// // minFontSize: 14,
// // maxFontSize: 500,
// // style: const TextStyle(
// // color: Colors.white, fontSize: 500),
// // ))
// ),
// ),
// ],
// ))
),
padding: EdgeInsets.fromLTRB(15, calcPadding(context) + 5,
8, calcPadding(context) + 5),
child: ConstrainedBox(
constraints: const BoxConstraints(
minHeight: 50,
maxHeight: 100,
),
child: AutoSizeText(
item.intervalString().isEmpty
? ""
: item.interval.toString(),
maxLines: 1,
minFontSize: 14,
maxFontSize: 500,
style: TextStyle(
color: fontColor,
fontSize: 500,
),
)))),
// Current interval text, "Work" if no exercise provided.
Expanded(
flex: 60,
Expand Down
6 changes: 3 additions & 3 deletions lib/helper_widgets/export_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ class ExportBottomSheet extends StatelessWidget {

await fileUtil.writeFile([workout!]);

ShareResult? result =
await fileUtil.shareFile([workout!]);

if (context.mounted) {
ShareResult? result =
await fileUtil.shareFile([workout!], context);

Navigator.pop(context);
ScaffoldMessenger.of(context).showSnackBar(
result!.status == ShareResultStatus.success
Expand Down
32 changes: 25 additions & 7 deletions lib/import_export/local_file_util.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:convert';
import 'dart:io';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:logger/logger.dart';
import 'package:openhiit/workout_data_type/workout_type.dart';
import 'package:path_provider/path_provider.dart';
Expand Down Expand Up @@ -56,28 +57,45 @@ class LocalFileUtil {
///
/// Returns an integer value indicating the success of the file sharing operation.
/// If the file sharing is successful, it returns 1. If an error occurs, it returns 0.
Future<ShareResult?> shareFile(List<Workout> workouts) async {
Future<ShareResult?> shareFile(
List<Workout> workouts, BuildContext context) async {
try {
final file = await localFilePath(workouts);

ShareResult result =
await Share.shareXFiles([XFile(file.path)], text: 'OpenHIIT Export');
if (context.mounted) {
final box = context.findRenderObject() as RenderBox?;

return result;
ShareResult result = await Share.shareXFiles([XFile(file.path)],
text: 'OpenHIIT Export',
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size);

return result;
}

return null;
} catch (e) {
// If encountering an error, return null
return null;
}
}

Future<ShareResult?> shareMultipleFiles(List<Workout> workouts) async {
Future<ShareResult?> shareMultipleFiles(
List<Workout> workouts, BuildContext context) async {
try {
List<XFile> files = [];

files.add(XFile((await localFilePath(workouts)).path));

ShareResult result = await Share.shareXFiles(files, text: 'Export');
return result;
if (context.mounted) {
final box = context.findRenderObject() as RenderBox?;

ShareResult result = await Share.shareXFiles(files,
text: 'Export',
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size);
return result;
}

return null;
} catch (e) {
// If encountering an error, return 0
return null;
Expand Down
6 changes: 6 additions & 0 deletions lib/log/log.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Global logger instance for logging messages
import 'package:logger/logger.dart';

var logger = Logger(
printer: PrettyPrinter(methodCount: 0),
);
Loading

0 comments on commit cdcd749

Please sign in to comment.