Compare commits
No commits in common. "b943666bb4a631e7cef596e7520c2857045fb301" and "6db702437f5d6b07223dc41e68886bc330e5e834" have entirely different histories.
b943666bb4
...
6db702437f
|
|
@ -52,7 +52,6 @@ import 'package:yimaru_app/services/in_app_update_service.dart';
|
|||
import 'package:yimaru_app/ui/views/learn_program/learn_program_view.dart';
|
||||
import 'package:yimaru_app/ui/views/learn_course/learn_course_view.dart';
|
||||
import 'package:yimaru_app/ui/views/assessment/assessment_view.dart';
|
||||
import 'package:yimaru_app/services/vimeo_service.dart';
|
||||
// @stacked-import
|
||||
|
||||
@StackedApp(
|
||||
|
|
@ -113,7 +112,6 @@ import 'package:yimaru_app/services/vimeo_service.dart';
|
|||
LazySingleton(classType: AudioPlayerService),
|
||||
LazySingleton(classType: VoiceRecorderService),
|
||||
LazySingleton(classType: InAppUpdateService),
|
||||
LazySingleton(classType: VimeoService),
|
||||
// @stacked-service
|
||||
],
|
||||
bottomsheets: [
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import '../services/permission_handler_service.dart';
|
|||
import '../services/secure_storage_service.dart';
|
||||
import '../services/smart_auth_service.dart';
|
||||
import '../services/status_checker_service.dart';
|
||||
import '../services/vimeo_service.dart';
|
||||
import '../services/voice_recorder_service.dart';
|
||||
|
||||
final locator = StackedLocator.instance;
|
||||
|
|
@ -56,5 +55,4 @@ Future<void> setupLocator(
|
|||
locator.registerLazySingleton(() => AudioPlayerService());
|
||||
locator.registerLazySingleton(() => VoiceRecorderService());
|
||||
locator.registerLazySingleton(() => InAppUpdateService());
|
||||
locator.registerLazySingleton(() => VimeoService());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -506,11 +506,10 @@ class ApiService {
|
|||
|
||||
final Response response = await _service.dio
|
||||
.get('$kBaseUrl/api/$kApiVersionUrl/$kModulesUrl/$id/$kPracticesUrl');
|
||||
print('MODULE PRACTICES: ${response.data}');
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
var data = response.data;
|
||||
var decodedData = data['data']['practices'] as List;
|
||||
var decodedData = data['data'] as List;
|
||||
practices = decodedData.map(
|
||||
(e) {
|
||||
return LearnPractice.fromJson(e);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:async/async.dart';
|
||||
import 'package:audioplayers/audioplayers.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
|
|
@ -12,19 +9,13 @@ class AudioPlayerService with ListenableServiceMixin {
|
|||
|
||||
AudioPlayer get player => _player;
|
||||
|
||||
final _durationController = StreamController<Duration>.broadcast();
|
||||
|
||||
AudioPlayerService() {
|
||||
_player.setReleaseMode(ReleaseMode.stop);
|
||||
}
|
||||
|
||||
// Streams
|
||||
Stream<Duration> get durationStream => StreamGroup.merge([
|
||||
_player.onDurationChanged,
|
||||
_durationController.stream,
|
||||
]);
|
||||
|
||||
Stream<Duration> get positionStream => _player.onPositionChanged;
|
||||
Stream<Duration> get durationStream => _player.onDurationChanged;
|
||||
|
||||
// Optional: player state
|
||||
Stream<PlayerState> get stateStream => _player.onPlayerStateChanged;
|
||||
|
|
@ -37,16 +28,10 @@ class AudioPlayerService with ListenableServiceMixin {
|
|||
}
|
||||
|
||||
await _player.play(UrlSource(playableUrl));
|
||||
|
||||
// 👇 Force duration fetch
|
||||
final dur = await _player.getDuration();
|
||||
if (dur != null) {
|
||||
_durationController.add(dur);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> playLocal(String url) async {
|
||||
await _player.play(DeviceFileSource(url));
|
||||
await _player.play(UrlSource(url));
|
||||
}
|
||||
|
||||
Future<void> pause() async => await _player.pause();
|
||||
|
|
|
|||
|
|
@ -148,8 +148,6 @@ class AuthenticationService with ListenableServiceMixin {
|
|||
|
||||
// Get user data
|
||||
Future<User?> getUser() async {
|
||||
print('GENDER:');
|
||||
print(await _secureService.getString('gender'));
|
||||
_user = User(
|
||||
userId: await _secureService.getInt('userId'),
|
||||
email: await _secureService.getString('email'),
|
||||
|
|
|
|||
|
|
@ -1,85 +0,0 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class VimeoService {
|
||||
Future<String?> getVideoUrl(String vimeoUrl) async {
|
||||
final videoId = _extractVideoId(vimeoUrl);
|
||||
|
||||
if (videoId == null) {
|
||||
throw Exception('Invalid Vimeo URL');
|
||||
}
|
||||
|
||||
final html = await _fetchHtml(videoId);
|
||||
|
||||
final config = _extractConfig(html);
|
||||
|
||||
if (config == null) {
|
||||
throw Exception('Failed to extract Vimeo config');
|
||||
}
|
||||
|
||||
return _extractHlsUrl(config);
|
||||
}
|
||||
|
||||
Future<String> _fetchHtml(String videoId) async {
|
||||
final response = await http.get(
|
||||
Uri.parse('https://player.vimeo.com/video/$videoId'),
|
||||
headers: {
|
||||
'Origin': 'https://vimeo.com',
|
||||
'Referer': 'https://vimeo.com/',
|
||||
'Accept': 'text/html,application/xhtml+xml',
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
|
||||
},
|
||||
);
|
||||
|
||||
return response.body;
|
||||
}
|
||||
|
||||
static Map<String, dynamic>? _extractConfig(String html) {
|
||||
final regex = RegExp(
|
||||
r'window\.playerConfig\s*=\s*({.*?})\s*</script>',
|
||||
dotAll: true,
|
||||
);
|
||||
|
||||
final match = regex.firstMatch(html);
|
||||
if (match == null) return null;
|
||||
|
||||
final jsonString = match.group(1);
|
||||
if (jsonString == null) return null;
|
||||
|
||||
return jsonDecode(jsonString);
|
||||
}
|
||||
|
||||
String? _extractHlsUrl(Map<String, dynamic> config) {
|
||||
try {
|
||||
final files = config['request']?['files'];
|
||||
final hls = files?['hls'];
|
||||
|
||||
if (hls == null) return null;
|
||||
|
||||
final cdns = hls['cdns'] as Map<String, dynamic>;
|
||||
|
||||
// Prefer fastly_skyfire or fallback to first CDN
|
||||
final cdn = cdns['fastly_skyfire'] ?? cdns.values.first;
|
||||
|
||||
return cdn['url'];
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
String? _extractVideoId(String url) {
|
||||
try {
|
||||
final uri = Uri.parse(url);
|
||||
|
||||
if (uri.pathSegments.isNotEmpty) {
|
||||
return uri.pathSegments.last;
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:waveform_recorder/waveform_recorder.dart';
|
||||
|
|
@ -37,19 +39,25 @@ class VoiceRecorderService with ListenableServiceMixin {
|
|||
|
||||
// Get recorded audio
|
||||
Future<String?> getRecordedAudio() async {
|
||||
final recorded = _waveController.file;
|
||||
if (recorded == null) return null;
|
||||
final file = _waveController.file;
|
||||
print('RECORDED $file');
|
||||
if (file == null) return null;
|
||||
|
||||
final generator = Random();
|
||||
await _saveRecordedAudio(file);
|
||||
|
||||
int random = generator.nextInt(100);
|
||||
// return file.path;
|
||||
String? voice = await _saveRecordedAudio(file);
|
||||
return voice;
|
||||
}
|
||||
|
||||
final dir = await getTemporaryDirectory();
|
||||
Future<String?> _saveRecordedAudio(XFile? file) async {
|
||||
late File voice;
|
||||
final voiceName = basename(file?.name ?? '');
|
||||
final Directory appDir = await getApplicationDocumentsDirectory();
|
||||
|
||||
final playable = File('${dir.path}/temp_audio_$random.aac');
|
||||
|
||||
await playable.writeAsBytes(await recorded.readAsBytes(), flush: true);
|
||||
|
||||
return playable.path;
|
||||
final localImagePath = join(appDir.path, voiceName);
|
||||
voice = File(localImagePath);
|
||||
//voice.writeAsBytes(await file?.);
|
||||
return voice.path;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
import 'dart:ui';
|
||||
|
||||
|
|
|
|||
|
|
@ -312,8 +312,9 @@ TextStyle style14MG400 = const TextStyle(
|
|||
TextStyle style14DG500 =
|
||||
const TextStyle(color: kcDarkGrey, fontWeight: FontWeight.w500);
|
||||
|
||||
TextStyle style18MG500 = const TextStyle(
|
||||
fontSize: 18, color: kcMediumGrey, fontWeight: FontWeight.w500);
|
||||
TextStyle style18MG500 =
|
||||
const TextStyle(fontSize: 18,color: kcMediumGrey, fontWeight: FontWeight.w500);
|
||||
|
||||
|
||||
TextStyle style14DG400 = const TextStyle(
|
||||
color: kcDarkGrey,
|
||||
|
|
|
|||
|
|
@ -69,17 +69,17 @@ class AssessmentViewModel extends BaseViewModel {
|
|||
Map<String, dynamic> get userData => _userData;
|
||||
|
||||
// Assessment
|
||||
Future<void> setFirstAssessment() async {
|
||||
Future<void> setFirstAssessment()async{
|
||||
_proficiencyLevel = null;
|
||||
_selectedAnswers.clear();
|
||||
_currentQuestionIndex = 0;
|
||||
_pageController.jumpToPage(_currentQuestionIndex);
|
||||
_currentAssessment = assessments[currentAssessmentIndex];
|
||||
await getAssessmentQuestions(_currentAssessment?.id ?? 0);
|
||||
_currentAssessment = assessments[currentAssessmentIndex];
|
||||
await getAssessmentQuestions(
|
||||
_currentAssessment?.id ?? 0);
|
||||
|
||||
next();
|
||||
}
|
||||
|
||||
Map<String, dynamic> evaluateAssessment() {
|
||||
bool levelPassed = canPassLevel();
|
||||
if (levelPassed) {
|
||||
|
|
@ -165,8 +165,9 @@ class AssessmentViewModel extends BaseViewModel {
|
|||
_selectedAnswers.clear();
|
||||
_currentQuestionIndex = 0;
|
||||
_proficiencyLevel = response['level'];
|
||||
_currentAssessment = assessments[currentAssessmentIndex];
|
||||
await getAssessmentQuestions(_currentAssessment?.id ?? 0);
|
||||
_currentAssessment = assessments[currentAssessmentIndex];
|
||||
await getAssessmentQuestions(
|
||||
_currentAssessment?.id ?? 0);
|
||||
_pageController.jumpToPage(_currentQuestionIndex);
|
||||
} else {
|
||||
_proficiencyLevel = response['level'];
|
||||
|
|
@ -273,8 +274,9 @@ class AssessmentViewModel extends BaseViewModel {
|
|||
}
|
||||
|
||||
// Assessments
|
||||
Future<void> getAssessments() async => await runBusyFuture(_getAssessments(),
|
||||
busyObject: StateObjects.assessments);
|
||||
Future<void> getAssessments() async =>
|
||||
await runBusyFuture(_getAssessments(),
|
||||
busyObject: StateObjects.assessments);
|
||||
|
||||
Future<void> _getAssessments() async {
|
||||
if (await _statusChecker.checkConnection()) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import 'package:yimaru_app/ui/widgets/custom_elevated_button.dart';
|
|||
import 'package:yimaru_app/ui/widgets/custom_small_radio_button.dart';
|
||||
import 'package:yimaru_app/ui/widgets/large_app_bar.dart';
|
||||
|
||||
import '../../../widgets/assessment_loading_screen.dart';
|
||||
import '../assessment_viewmodel.dart';
|
||||
|
||||
class AssessmentQuestionsScreen extends ViewModelWidget<AssessmentViewModel> {
|
||||
|
|
@ -139,8 +140,7 @@ class AssessmentQuestionsScreen extends ViewModelWidget<AssessmentViewModel> {
|
|||
onTap: viewModel.selectedAnswers.containsKey(question.toString())
|
||||
? () => viewModel.nextQuestion()
|
||||
: null,
|
||||
text: viewModel.currentQuestionIndex ==
|
||||
viewModel.assessmentQuestions.length - 1
|
||||
text: viewModel.currentQuestionIndex == viewModel.assessmentQuestions.length - 1
|
||||
? 'Finish Level'
|
||||
: 'Continue',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:yimaru_app/ui/common/app_colors.dart';
|
||||
import 'package:yimaru_app/ui/common/enmus.dart';
|
||||
import 'package:yimaru_app/ui/common/ui_helpers.dart';
|
||||
import 'package:yimaru_app/ui/widgets/custom_elevated_button.dart';
|
||||
import 'package:yimaru_app/ui/widgets/large_app_bar.dart';
|
||||
|
|
@ -86,7 +87,9 @@ class AssessmentResultScreen extends ViewModelWidget<AssessmentViewModel> {
|
|||
);
|
||||
|
||||
Widget _buildIconWrapper(AssessmentViewModel viewModel) =>
|
||||
viewModel.proficiencyLevel != null ? _buildIcon(viewModel) : Container();
|
||||
viewModel.proficiencyLevel != null
|
||||
? _buildIcon(viewModel)
|
||||
: Container();
|
||||
|
||||
Widget _buildIcon(AssessmentViewModel viewModel) => SvgPicture.asset(
|
||||
'assets/icons/${viewModel.proficiencyLevel?.substring(0, 1).toLowerCase()}_${viewModel.proficiencyLevel?.substring(1).toLowerCase()}.svg');
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import 'package:yimaru_app/ui/views/learn_program/learn_program_view.dart';
|
|||
import 'package:yimaru_app/ui/views/profile/profile_view.dart';
|
||||
import 'package:yimaru_app/ui/widgets/coming_soon.dart';
|
||||
|
||||
import '../../common/enmus.dart';
|
||||
import '../../widgets/page_loading_indicator.dart';
|
||||
import 'home_viewmodel.dart';
|
||||
|
||||
class HomeView extends StackedView<HomeViewModel> {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
import 'package:chewie/chewie.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:vimeo_video_player/vimeo_video_player.dart';
|
||||
import 'package:yimaru_app/models/learn_lesson.dart';
|
||||
|
||||
import '../../common/app_colors.dart';
|
||||
import '../../common/enmus.dart';
|
||||
import '../../common/ui_helpers.dart';
|
||||
import '../../widgets/custom_elevated_button.dart';
|
||||
import '../../widgets/empty_video_player.dart';
|
||||
import '../../widgets/small_app_bar.dart';
|
||||
import 'learn_lesson_detail_viewmodel.dart';
|
||||
|
||||
|
|
@ -23,12 +20,6 @@ class LearnLessonDetailView extends StackedView<LearnLessonDetailViewModel> {
|
|||
await viewModel.navigateToLearnPractice(lesson.id ?? 0);
|
||||
}
|
||||
|
||||
@override
|
||||
void onViewModelReady(LearnLessonDetailViewModel viewModel) async {
|
||||
await viewModel.initializePlayer(lesson.videoUrl ?? '');
|
||||
super.onViewModelReady(viewModel);
|
||||
}
|
||||
|
||||
@override
|
||||
void onDispose(LearnLessonDetailViewModel viewModel) {
|
||||
viewModel.close();
|
||||
|
|
@ -129,23 +120,19 @@ class LearnLessonDetailView extends StackedView<LearnLessonDetailViewModel> {
|
|||
height: 200,
|
||||
color: kcBlack,
|
||||
width: double.maxFinite,
|
||||
child: _buildVideoPlayerState(viewModel),
|
||||
child: _buildVideoPlayer(viewModel),
|
||||
);
|
||||
|
||||
Widget _buildVideoPlayerState(LearnLessonDetailViewModel viewModel) =>
|
||||
viewModel.chewieController != null &&
|
||||
viewModel.videoPlayerController != null &&
|
||||
!viewModel.busy(StateObjects.loadLessonVideo)
|
||||
? _buildVideoPlayer(viewModel)
|
||||
: _buildEmptyVideoPlayer();
|
||||
|
||||
Widget _buildVideoPlayer(LearnLessonDetailViewModel viewModel) =>
|
||||
_buildChewiePlayer(viewModel);
|
||||
_buildVimeoPlayer(viewModel);
|
||||
|
||||
Widget _buildChewiePlayer(LearnLessonDetailViewModel viewModel) =>
|
||||
Chewie(controller: viewModel.chewieController!);
|
||||
|
||||
Widget _buildEmptyVideoPlayer() => const EmptyVideoPlayer();
|
||||
Widget _buildVimeoPlayer(LearnLessonDetailViewModel viewModel) =>
|
||||
VimeoVideoPlayer(
|
||||
isAutoPlay: true,
|
||||
onInAppWebViewCreated: (controller) =>
|
||||
viewModel.initializePlayer(controller),
|
||||
videoId: lesson.videoUrl?.split('/').last ?? '',
|
||||
);
|
||||
|
||||
Widget _buildDescriptionWrapper() => Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||
|
|
|
|||
|
|
@ -1,67 +1,45 @@
|
|||
import 'package:chewie/chewie.dart';
|
||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
import 'package:yimaru_app/ui/common/enmus.dart';
|
||||
|
||||
import '../../../app/app.locator.dart';
|
||||
import '../../../app/app.router.dart';
|
||||
import '../../../services/status_checker_service.dart';
|
||||
import '../../../services/vimeo_service.dart';
|
||||
import '../../common/app_constants.dart';
|
||||
import '../../common/helper_functions.dart';
|
||||
import '../../common/ui_helpers.dart';
|
||||
|
||||
class LearnLessonDetailViewModel extends BaseViewModel {
|
||||
// Dependency injection
|
||||
final _vimeoService = locator<VimeoService>();
|
||||
final _statusChecker = locator<StatusCheckerService>();
|
||||
|
||||
final _navigationService = locator<NavigationService>();
|
||||
|
||||
// Video player config
|
||||
ChewieController? _chewieController;
|
||||
InAppWebViewController? _webViewController;
|
||||
|
||||
ChewieController? get chewieController => _chewieController;
|
||||
|
||||
VideoPlayerController? _videoPlayerController;
|
||||
|
||||
VideoPlayerController? get videoPlayerController => _videoPlayerController;
|
||||
InAppWebViewController? get webViewController => _webViewController;
|
||||
|
||||
// Video player
|
||||
void close() {
|
||||
_videoPlayerController?.dispose();
|
||||
_chewieController?.dispose();
|
||||
webViewController?.dispose();
|
||||
}
|
||||
|
||||
Future<void> pause() async {
|
||||
await _chewieController?.pause();
|
||||
await webViewController?.pause();
|
||||
}
|
||||
|
||||
Future<void> initializePlayer(String url) async =>
|
||||
await runBusyFuture(_initializePlayer(url),
|
||||
busyObject: StateObjects.loadLessonVideo);
|
||||
void initializePlayer(InAppWebViewController controller) {
|
||||
_webViewController = controller;
|
||||
rebuildUi();
|
||||
}
|
||||
|
||||
Future<void> _initializePlayer(String url) async {
|
||||
final playableUrl = await _vimeoService.getVideoUrl(url);
|
||||
void onLoadVideoStart() {
|
||||
setBusyForObject(StateObjects.loadLessonVideo, true);
|
||||
rebuildUi();
|
||||
}
|
||||
|
||||
if (playableUrl == null) {
|
||||
throw Exception("Unable to load video");
|
||||
}
|
||||
|
||||
_videoPlayerController =
|
||||
VideoPlayerController.networkUrl(Uri.parse(playableUrl));
|
||||
|
||||
await _videoPlayerController?.initialize();
|
||||
|
||||
_chewieController = ChewieController(
|
||||
videoPlayerController: _videoPlayerController!,
|
||||
autoPlay: true,
|
||||
looping: true,
|
||||
aspectRatio: 16 / 9,
|
||||
);
|
||||
|
||||
notifyListeners();
|
||||
void onLoadVideoComplete() {
|
||||
setBusyForObject(StateObjects.loadLessonVideo, false);
|
||||
rebuildUi();
|
||||
}
|
||||
|
||||
// Navigation
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ class LearnPracticeView extends StackedView<LearnPracticeViewModel> {
|
|||
: super(key: key);
|
||||
|
||||
Future<void> _cancel(LearnPracticeViewModel viewModel) async {
|
||||
await viewModel.stopRecording();
|
||||
viewModel.pop();
|
||||
viewModel.stopRecording();
|
||||
viewModel.pop();
|
||||
}
|
||||
|
||||
|
|
@ -59,12 +59,8 @@ class LearnPracticeView extends StackedView<LearnPracticeViewModel> {
|
|||
required LearnPracticeViewModel viewModel}) =>
|
||||
PopScope(
|
||||
canPop: false,
|
||||
onPopInvokedWithResult: (didPop, data) {
|
||||
if (!didPop) {
|
||||
Future.microtask(() async =>
|
||||
await _showSheet(context: context, viewModel: viewModel));
|
||||
}
|
||||
},
|
||||
onPopInvokedWithResult: (value, data) async =>
|
||||
await _showSheet(context: context, viewModel: viewModel),
|
||||
child: _buildScaffoldWrapper(viewModel));
|
||||
|
||||
Widget _buildSheet(LearnPracticeViewModel viewModel) =>
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ class LearnPracticeViewModel extends ReactiveViewModel {
|
|||
Duration get duration => _duration;
|
||||
|
||||
double get progress {
|
||||
print('DURATION: ${_duration.inMilliseconds}');
|
||||
if (_duration.inMilliseconds == 0) return 0;
|
||||
return _position.inMilliseconds / _duration.inMilliseconds;
|
||||
}
|
||||
|
|
@ -129,14 +128,14 @@ class LearnPracticeViewModel extends ReactiveViewModel {
|
|||
// Play practice audio
|
||||
void _listenToAudio() {
|
||||
_audioPlayerService.durationStream.listen((dur) {
|
||||
if (dur.inMilliseconds > 0) {
|
||||
_duration = dur;
|
||||
rebuildUi();
|
||||
}
|
||||
_duration = dur;
|
||||
print('DURATION: $_duration');
|
||||
rebuildUi();
|
||||
});
|
||||
|
||||
_audioPlayerService.positionStream.listen((pos) {
|
||||
_position = pos;
|
||||
print('POSITION: $_position');
|
||||
rebuildUi();
|
||||
});
|
||||
}
|
||||
|
|
@ -256,14 +255,13 @@ class LearnPracticeViewModel extends ReactiveViewModel {
|
|||
if (await _statusChecker.checkConnection()) {
|
||||
if (practice == LearnPractices.course) {
|
||||
_practices = await _apiService.getLearnCoursePractices(id);
|
||||
|
||||
await _getLearnPracticeQuestions(_practices.first.questionSetId ?? 0);
|
||||
} else if (practice == LearnPractices.module) {
|
||||
_practices = await _apiService.getLearnModulePractices(id);
|
||||
await _getLearnPracticeQuestions(_practices.first.questionSetId ?? 0);
|
||||
} else {
|
||||
_practices = await _apiService.getLearnLessonPractices(id);
|
||||
|
||||
print('PRACTICE LENGTH: ${_practices.length}');
|
||||
await _getLearnPracticeQuestions(_practices.first.questionSetId ?? 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import 'package:yimaru_app/ui/views/learn_practice/learn_practice_viewmodel.dart
|
|||
import 'package:yimaru_app/ui/widgets/cancel_learn_practice_sheet.dart';
|
||||
import 'package:yimaru_app/ui/widgets/custom_circular_progress_indicator.dart';
|
||||
import 'package:yimaru_app/ui/widgets/custom_linear_progress_indicator.dart';
|
||||
import 'package:yimaru_app/ui/widgets/page_loading_indicator.dart';
|
||||
import 'package:yimaru_app/ui/widgets/wave_wrapper.dart';
|
||||
|
||||
import '../../../../models/learn_question.dart';
|
||||
|
|
@ -25,9 +26,9 @@ class InteractLearnPracticeScreen
|
|||
{super.key, required this.index, required this.question});
|
||||
|
||||
Future<void> _cancel(LearnPracticeViewModel viewModel) async {
|
||||
await viewModel.stopRecording();
|
||||
viewModel.pop();
|
||||
viewModel.pop();
|
||||
viewModel.stopRecording();
|
||||
}
|
||||
|
||||
void _reply(LearnPracticeViewModel viewModel) =>
|
||||
|
|
@ -164,10 +165,10 @@ class InteractLearnPracticeScreen
|
|||
? Container()
|
||||
: viewModel.player.state == PlayerState.playing
|
||||
? _buildSpinner()
|
||||
: VoiceRecordingState.recording == viewModel.recordingState &&
|
||||
viewModel.waveController.isRecording
|
||||
? _buildSpeakingSpinnerColumn(viewModel)
|
||||
: Container();
|
||||
: VoiceRecordingState.recording == viewModel.recordingState &&
|
||||
viewModel.waveController.isRecording
|
||||
? _buildSpeakingSpinnerColumn(viewModel)
|
||||
: Container();
|
||||
|
||||
Widget _buildSpeakingSpinnerColumn(LearnPracticeViewModel viewModel) =>
|
||||
Column(
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import 'package:yimaru_app/ui/widgets/small_app_bar.dart';
|
|||
|
||||
import '../../../common/app_colors.dart';
|
||||
import '../../../common/ui_helpers.dart';
|
||||
import '../../../widgets/large_app_bar.dart';
|
||||
import '../../../widgets/refresh_button.dart';
|
||||
|
||||
class LearnLoadingScreen extends StatelessWidget {
|
||||
final bool isEmpty;
|
||||
|
|
@ -56,11 +58,9 @@ class LearnLoadingScreen extends StatelessWidget {
|
|||
|
||||
Widget _buildPageIndicator() => const PageLoadingIndicator();
|
||||
|
||||
Widget _buildRefreshButtonWrapper() =>
|
||||
Align(alignment: Alignment.center, child: _buildRefreshButton());
|
||||
Widget _buildRefreshButtonWrapper() => Align(
|
||||
alignment: Alignment.center,
|
||||
child:_buildRefreshButton());
|
||||
|
||||
Widget _buildRefreshButton() => NoDataIndicator(
|
||||
title: 'No practice available!',
|
||||
onTap: onTap,
|
||||
);
|
||||
Widget _buildRefreshButton()=> NoDataIndicator(title:'No practice available!' ,onTap: onTap,);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ class LearnPracticeIntroScreen extends ViewModelWidget<LearnPracticeViewModel> {
|
|||
const LearnPracticeIntroScreen({super.key});
|
||||
|
||||
Future<void> _cancel(LearnPracticeViewModel viewModel) async {
|
||||
await viewModel.stopRecording();
|
||||
viewModel.pop();
|
||||
viewModel.pop();
|
||||
viewModel.stopRecording();
|
||||
}
|
||||
|
||||
Future<void> _showSheet(
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ class LearnPracticeQuestionsScreen
|
|||
required LearnQuestion question,
|
||||
}) =>
|
||||
[
|
||||
if (index == 1)
|
||||
_buildStartLearnPracticeScreen(index: index, question: question),
|
||||
if(index ==1) _buildStartLearnPracticeScreen(index: index, question: question),
|
||||
_buildInteractLearnPracticeScreen(index: index, question: question)
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ class LearnPracticeResultScreen
|
|||
}
|
||||
|
||||
Future<void> _cancel(LearnPracticeViewModel viewModel) async {
|
||||
await viewModel.stopRecording();
|
||||
viewModel.pop();
|
||||
viewModel.pop();
|
||||
viewModel.stopRecording();
|
||||
}
|
||||
|
||||
Future<void> _showSheet(
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ class StartLearnPracticeScreen extends ViewModelWidget<LearnPracticeViewModel> {
|
|||
{super.key, required this.index, required this.question});
|
||||
|
||||
Future<void> _cancel(LearnPracticeViewModel viewModel) async {
|
||||
await viewModel.stopRecording();
|
||||
viewModel.pop();
|
||||
viewModel.pop();
|
||||
viewModel.stopRecording();
|
||||
}
|
||||
|
||||
void _start(LearnPracticeViewModel viewModel) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import 'package:stacked/stacked.dart';
|
|||
import 'package:yimaru_app/ui/common/app_colors.dart';
|
||||
import 'package:yimaru_app/ui/common/enmus.dart';
|
||||
import 'package:yimaru_app/ui/common/ui_helpers.dart';
|
||||
import 'package:yimaru_app/ui/widgets/page_loading_indicator.dart';
|
||||
import 'package:yimaru_app/ui/widgets/profile_card.dart';
|
||||
import 'package:yimaru_app/ui/widgets/profile_image.dart';
|
||||
import 'package:yimaru_app/ui/widgets/view_profile_button.dart';
|
||||
|
|
@ -155,7 +156,7 @@ class ProfileView extends StackedView<ProfileViewModel> {
|
|||
children: _buildSettingsChildren(viewModel));
|
||||
|
||||
List<Widget> _buildSettingsChildren(ProfileViewModel viewModel) => [
|
||||
// _buildDownloadsCard(viewModel),
|
||||
// _buildDownloadsCard(viewModel),
|
||||
_buildProgressCard(viewModel),
|
||||
_buildAccountCard(viewModel),
|
||||
_buildSupportCard(viewModel)
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ class ProfileDetailView extends StackedView<ProfileDetailViewModel>
|
|||
|
||||
Widget _buildMaleRadioTile(ProfileDetailViewModel viewModel) =>
|
||||
RadioListTile<String?>(
|
||||
value: 'male',
|
||||
value: 'Male',
|
||||
title: _buildMaleTitle(),
|
||||
activeColor: kcPrimaryColor,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
|
|
@ -400,7 +400,7 @@ class ProfileDetailView extends StackedView<ProfileDetailViewModel>
|
|||
|
||||
Widget _buildFemaleRadioTile(ProfileDetailViewModel viewModel) =>
|
||||
RadioListTile<String?>(
|
||||
value: 'female',
|
||||
value: 'Female',
|
||||
title: _buildFemaleTitle(),
|
||||
activeColor: kcPrimaryColor,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
|
|
|
|||
|
|
@ -47,8 +47,7 @@ class StartupViewModel extends ReactiveViewModel {
|
|||
}
|
||||
|
||||
// Navigation
|
||||
Future<void> replaceWithFailure() async =>
|
||||
await _navigationService.replaceWithFailureView(
|
||||
Future<void> replaceWithFailure() async => await _navigationService.replaceWithFailureView(
|
||||
label: 'Check you internet connection',
|
||||
onTap: () async => await _getProfileStatus());
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import 'package:audioplayers/audioplayers.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:yimaru_app/ui/widgets/custom_circular_progress_indicator.dart';
|
||||
|
||||
import '../common/app_colors.dart';
|
||||
import '../common/enmus.dart';
|
||||
|
|
@ -51,22 +50,13 @@ class LearnPracticeAnswerCard extends ViewModelWidget<LearnPracticeViewModel> {
|
|||
);
|
||||
|
||||
Widget _buildButtonState(LearnPracticeViewModel viewModel) =>
|
||||
viewModel.busyObject == answer['busy_object'] &&
|
||||
viewModel.playing == voice
|
||||
? viewModel.busy(answer['busy_object'])
|
||||
? _buildProgressIndicatorWrapper()
|
||||
: viewModel.player.state == PlayerState.playing
|
||||
? _buildPauseIcon()
|
||||
: _buildPlayIcon()
|
||||
(viewModel.busy(answer['busy_object']) && viewModel.playing == voice) ||
|
||||
(viewModel.busyObject == answer['busy_object'] &&
|
||||
viewModel.playing == voice &&
|
||||
viewModel.player.state == PlayerState.playing)
|
||||
? _buildPauseIcon()
|
||||
: _buildPlayIcon();
|
||||
|
||||
Widget _buildProgressIndicatorWrapper() => Center(
|
||||
child: _buildProgressIndicator(),
|
||||
);
|
||||
|
||||
Widget _buildProgressIndicator() =>
|
||||
const CustomCircularProgressIndicator(color: kcWhite);
|
||||
|
||||
Widget _buildPlayIcon() => const Icon(
|
||||
Icons.play_arrow_rounded,
|
||||
size: 25,
|
||||
|
|
|
|||
|
|
@ -46,6 +46,5 @@ class LearnPracticeResultsWrapper
|
|||
itemBuilder: (context, index) => _buildResult(viewModel.answers[index]),
|
||||
);
|
||||
|
||||
Widget _buildResult(Map<String, dynamic> answer) =>
|
||||
LearnPracticeResultCard(answer: answer);
|
||||
Widget _buildResult(Map<String, dynamic> answer) => LearnPracticeResultCard(answer: answer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,10 @@ class NoDataIndicator extends StatelessWidget {
|
|||
);
|
||||
|
||||
List<Widget> _buildColumnChildren() => [
|
||||
_buildIconWrapper(),
|
||||
_buildIconWrapper(),
|
||||
verticalSpaceMedium,
|
||||
_buildTitle(),
|
||||
|
||||
];
|
||||
|
||||
Widget _buildTitle() => Text(
|
||||
|
|
@ -30,13 +31,15 @@ class NoDataIndicator extends StatelessWidget {
|
|||
);
|
||||
|
||||
Widget _buildIconWrapper() => GestureDetector(
|
||||
onTap: onTap,
|
||||
child: _buildIcon(),
|
||||
);
|
||||
onTap: onTap,
|
||||
child: _buildIcon(),
|
||||
);
|
||||
|
||||
Widget _buildIcon() => const Icon(
|
||||
Icons.replay,
|
||||
size: 75,
|
||||
color: kcPrimaryColor,
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,13 +50,13 @@ packages:
|
|||
source: hosted
|
||||
version: "2.7.0"
|
||||
async:
|
||||
dependency: "direct main"
|
||||
dependency: transitive
|
||||
description:
|
||||
name: async
|
||||
sha256: e2eb0491ba5ddb6177742d2da23904574082139b07c1e33b8503b9f46f3e1a37
|
||||
sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.13.1"
|
||||
version: "2.13.0"
|
||||
audioplayers:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
name: yimaru_app
|
||||
version: 0.1.11+13
|
||||
version: 0.1.10+12
|
||||
publish_to: 'none'
|
||||
description: A new Flutter project.
|
||||
|
||||
|
|
@ -12,7 +12,6 @@ dependencies:
|
|||
intl: any
|
||||
dio: ^5.9.0
|
||||
path: ^1.9.1
|
||||
async: ^2.13.1
|
||||
pinput: ^6.0.1
|
||||
stacked: ^3.4.0
|
||||
iconsax: ^0.0.8
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import 'package:yimaru_app/services/course_service.dart';
|
|||
import 'package:yimaru_app/services/audio_player_service.dart';
|
||||
import 'package:yimaru_app/services/voice_recorder_service.dart';
|
||||
import 'package:yimaru_app/services/in_app_update_service.dart';
|
||||
import 'package:yimaru_app/services/vimeo_service.dart';
|
||||
// @stacked-import
|
||||
|
||||
import 'test_helpers.mocks.dart';
|
||||
|
|
@ -45,8 +44,6 @@ import 'test_helpers.mocks.dart';
|
|||
MockSpec<AudioPlayerService>(onMissingStub: OnMissingStub.returnDefault),
|
||||
MockSpec<VoiceRecorderService>(onMissingStub: OnMissingStub.returnDefault),
|
||||
MockSpec<InAppUpdateService>(onMissingStub: OnMissingStub.returnDefault),
|
||||
MockSpec<VimeoService>(onMissingStub: OnMissingStub.returnDefault),
|
||||
MockSpec<VimeoService>(onMissingStub: OnMissingStub.returnDefault),
|
||||
// @stacked-mock-spec
|
||||
],
|
||||
)
|
||||
|
|
@ -69,8 +66,6 @@ void registerServices() {
|
|||
getAndRegisterAudioPlayerService();
|
||||
getAndRegisterVoiceRecorderService();
|
||||
getAndRegisterInAppUpdateService();
|
||||
getAndRegisterVimeoService();
|
||||
getAndRegisterVimeoService();
|
||||
// @stacked-mock-register
|
||||
}
|
||||
|
||||
|
|
@ -232,13 +227,6 @@ MockInAppUpdateService getAndRegisterInAppUpdateService() {
|
|||
locator.registerSingleton<InAppUpdateService>(service);
|
||||
return service;
|
||||
}
|
||||
|
||||
MockVimeoService getAndRegisterVimeoService() {
|
||||
_removeRegistrationIfExists<VimeoService>();
|
||||
final service = MockVimeoService();
|
||||
locator.registerSingleton<VimeoService>(service);
|
||||
return service;
|
||||
}
|
||||
// @stacked-mock-create
|
||||
|
||||
void _removeRegistrationIfExists<T extends Object>() {
|
||||
|
|
|
|||
2133
test/helpers/test_helpers.mocks.dart
Normal file
2133
test/helpers/test_helpers.mocks.dart
Normal file
File diff suppressed because it is too large
Load Diff
|
|
@ -1,11 +0,0 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:yimaru_app/app/app.locator.dart';
|
||||
|
||||
import '../helpers/test_helpers.dart';
|
||||
|
||||
void main() {
|
||||
group('VimeoServiceTest -', () {
|
||||
setUp(() => registerServices());
|
||||
tearDown(() => locator.reset());
|
||||
});
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user