You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
3.9 KiB
Dart
92 lines
3.9 KiB
Dart
|
3 years ago
|
import 'dart:async';
|
||
|
|
import 'dart:ui' as ui;
|
||
|
|
|
||
|
|
import 'package:easy_localization/easy_localization.dart';
|
||
|
|
import 'package:flutter/material.dart';
|
||
|
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
||
|
|
import 'package:mohem_flutter_app/config/routes.dart';
|
||
|
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||
|
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
||
|
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||
|
|
import 'package:mohem_flutter_app/ui/marathon/marathon_provider.dart';
|
||
|
|
import 'package:provider/provider.dart';
|
||
|
|
import 'package:video_player/video_player.dart';
|
||
|
|
|
||
|
|
class SponsorVideoScreen extends StatelessWidget {
|
||
|
|
const SponsorVideoScreen({Key? key}) : super(key: key);
|
||
|
|
|
||
|
|
Future<void> onSponsorVideoClosed(BuildContext context) async {
|
||
|
|
Navigator.pop(context);
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
MarathonProvider provider = context.watch<MarathonProvider>();
|
||
|
|
return WillPopScope(
|
||
|
|
onWillPop: () {
|
||
|
|
provider.videoController.dispose();
|
||
|
|
return Future<bool>.value(true);
|
||
|
|
},
|
||
|
|
child: Scaffold(
|
||
|
|
backgroundColor: MyColors.black,
|
||
|
|
body: SafeArea(
|
||
|
|
child: Stack(
|
||
|
|
children: <Widget>[
|
||
|
|
Align(
|
||
|
|
child: provider.videoController.value.isInitialized
|
||
|
|
? AspectRatio(
|
||
|
|
aspectRatio: provider.videoController.value.aspectRatio,
|
||
|
|
child: VideoPlayer(provider.videoController),
|
||
|
|
)
|
||
|
|
: Container(color: Colors.white),
|
||
|
|
),
|
||
|
|
Align(
|
||
|
|
alignment: Alignment.topRight,
|
||
|
|
child: Container(
|
||
|
|
decoration: BoxDecoration(
|
||
|
|
color: MyColors.white,
|
||
|
|
shape: provider.totalSponsorVideoSeconds == 0 ? BoxShape.circle : BoxShape.rectangle,
|
||
|
|
borderRadius: provider.totalSponsorVideoSeconds == 0 ? null : BorderRadius.circular(15),
|
||
|
|
),
|
||
|
|
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 8),
|
||
|
|
child: provider.totalSponsorVideoSeconds == 0
|
||
|
|
? InkWell(
|
||
|
|
onTap: () {
|
||
|
|
Navigator.pop(context);
|
||
|
|
provider.videoController.dispose();
|
||
|
|
provider.buildConnectionWithSignalR(AppRoutes.navigatorKey.currentState!.overlay!.context);
|
||
|
|
},
|
||
|
|
child: const Icon(Icons.close, size: 12),
|
||
|
|
)
|
||
|
|
: Directionality(
|
||
|
|
textDirection: ui.TextDirection.ltr,
|
||
|
|
child: ("${LocaleKeys.ourSponsor.tr()} ${provider.totalSponsorVideoSeconds < 10 ? "0" : ""}${provider.totalSponsorVideoSeconds}").toText12(color: MyColors.darkTextColor),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
).paddingOnly(top: 20, right: 18),
|
||
|
|
Align(
|
||
|
|
alignment: Alignment.topLeft,
|
||
|
|
child: InkWell(
|
||
|
|
onTap: () {
|
||
|
|
Navigator.pop(context);
|
||
|
|
provider.videoController.dispose();
|
||
|
|
provider.buildConnectionWithSignalR(AppRoutes.navigatorKey.currentState!.overlay!.context);
|
||
|
|
},
|
||
|
|
child: Container(
|
||
|
|
decoration: BoxDecoration(color: MyColors.white, borderRadius: BorderRadius.circular(15)),
|
||
|
|
padding: const EdgeInsets.symmetric(vertical: 3, horizontal: 6),
|
||
|
|
child: Directionality(
|
||
|
|
textDirection: ui.TextDirection.ltr,
|
||
|
|
child: LocaleKeys.skip.tr().toText11(color: MyColors.darkTextColor),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
).paddingOnly(top: 20, left: 18),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|