Skip to content

Commit

Permalink
add app terms required by google
Browse files Browse the repository at this point in the history
  • Loading branch information
hatemragab committed Dec 20, 2021
1 parent c6a42f8 commit 2eca2c6
Show file tree
Hide file tree
Showing 22 changed files with 210 additions and 39 deletions.
42 changes: 42 additions & 0 deletions example/lib/app_terms.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:flutter/material.dart';
import 'package:textless/textless.dart';

class AppTerms extends StatefulWidget {
const AppTerms({Key? key}) : super(key: key);

@override
_AppTermsState createState() => _AppTermsState();
}

class _AppTermsState extends State<AppTerms> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Terms"),
centerTitle: true,
elevation: 0,
),
body: Column(
children: [
"* By entering and participating in the v chat 's you agree to the following terms and conditions of participation. "
.text,
"* These terms and conditions are contractually binding upon you and you agree to each of them. "
.text,
"* You enter and participate in the Chat Room and gain access to the materials contained thereon at your own risk."
.text,
"* We do not monitor or screen communications on the Chat Room and we are not responsible for any material that any Chat Room participant posts and we do not assume the responsibility to do so. "
.text,
"* We do not make any representations or warranties as to the truth or accuracy of any statement made or materials posted on or through the Chat Room. You agree and acknowledge that you assume the risk of any actions you take in reliance upon the information that may be contained in the Chat Room. "
.text,
"* We do not endorse or lend any credence for any statements that are made by any participant in the Chat Room. "
.text,
"* Any opinions or views expressed by Chat Room participants are their own. We do not endorse or support or otherwise give any credence or reason for reliance on any such statements or opinions. "
.text,
"* You are fully responsible for your own statements and materials that you post in the Chat Room and any consequences, whether or not foreseen, to any party who may rely upon these statements. "
.text,
],
),
);
}
}
4 changes: 4 additions & 0 deletions example/lib/controllers/login_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class LoginController {
BuildContext context;
final emailTxtController = TextEditingController();
final passwordTxtController = TextEditingController();
bool appTerms = false;

LoginController(this.context);

Expand All @@ -17,6 +18,9 @@ class LoginController {
//final password = passwordTxtController.text.toString();
try {
CustomAlert.customLoadingDialog(context: context);
if (!appTerms) {
throw "accept v chat terms to use the app";
}

///First Login on your system backend
///Once success login then start login to v chat sdk
Expand Down
5 changes: 4 additions & 1 deletion example/lib/controllers/register_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class RegisterController {
final emailTxtController = TextEditingController();
final nameTxtController = TextEditingController();
final passwordTxtController = TextEditingController();

bool appTerms = false;
String? imagePath;

RegisterController(this.context);
Expand All @@ -22,6 +22,9 @@ class RegisterController {

try {
CustomAlert.customLoadingDialog(context: context);
if (!appTerms) {
throw "accept v chat terms to use the app";
}

/// your image validation
if (imagePath != null) {
Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void main() async {
enableLogger: true,
maxMediaUploadSize: 50 * 1000 * 1000,
passwordHashKey: "passwordHashKey",
maxGroupChatUsers: 500,
maxGroupChatUsers: 512,
);

/// add support new language
Expand Down
34 changes: 30 additions & 4 deletions example/lib/screens/login_screen.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:example/app_terms.dart';
import 'package:example/generated/l10n.dart';
import 'package:flutter/material.dart';
import 'package:textless/textless.dart';
Expand Down Expand Up @@ -59,15 +60,40 @@ class _LoginScreenState extends State<LoginScreen> {
const SizedBox(
height: 10,
),
Row(
children: [
Checkbox(
value: _controller.appTerms,
onChanged: (v) {
setState(() {
_controller.appTerms = v!;
});
}),
const SizedBox(
width: 10,
),
InkWell(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (_) => AppTerms()));
},
child: "accept V Chat terms".text.color(Colors.blue))
],
),
const SizedBox(
height: 10,
),
ElevatedButton(
onPressed: _controller.login,
child: S.of(context).login.text),
onPressed: _controller.login,
child: S.of(context).login.text,
),
const SizedBox(
height: 10,
),
TextButton(
onPressed: _controller.register,
child: S.of(context).register.text),
onPressed: _controller.register,
child: S.of(context).register.text,
),
],
),
),
Expand Down
24 changes: 24 additions & 0 deletions example/lib/screens/register_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:example/utils/custom_alert.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:textless/textless.dart';
import '../app_terms.dart';
import '../controllers/register_controller.dart';

class RegisterScreen extends StatefulWidget {
Expand Down Expand Up @@ -72,6 +73,29 @@ class _RegisterScreenState extends State<RegisterScreen> {
const SizedBox(
height: 20,
),
Row(
children: [
Checkbox(
value: _controller.appTerms,
onChanged: (v) {
setState(() {
_controller.appTerms = v!;
});
}),
const SizedBox(
width: 10,
),
InkWell(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (_) => AppTerms()));
},
child: "accept V Chat terms".text.color(Colors.blue))
],
),
const SizedBox(
height: 10,
),
InkWell(
onTap: () async {
final picker = ImagePicker();
Expand Down
3 changes: 3 additions & 0 deletions example/lib/screens/setting_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,20 @@ class _SettingScreenState extends State<SettingScreen> {
await GetStorage().write("lng", "ar");
Provider.of<AppController>(context, listen: false)
.setLocale(const Locale.fromSubtags(languageCode: "ar"));
await VChatController.instance.changeLanguage("ar");
}
if (res == 1) {
await GetStorage().write("lng", "en");
Provider.of<AppController>(context, listen: false)
.setLocale(const Locale.fromSubtags(languageCode: "en"));
await VChatController.instance.changeLanguage("en");
}
if (res == 2) {
await GetStorage().write("lng", "pt_BR");
Provider.of<AppController>(context, listen: false).setLocale(
const Locale.fromSubtags(
languageCode: "pt", countryCode: "BR"));
await VChatController.instance.changeLanguage("pt_BR");
}
},
),
Expand Down
6 changes: 3 additions & 3 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.0"
version: "1.0.1"
vector_math:
dependency: transitive
description:
Expand All @@ -900,7 +900,7 @@ packages:
name: video_player
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.7"
version: "2.2.8"
video_player_platform_interface:
dependency: transitive
description:
Expand Down Expand Up @@ -1000,5 +1000,5 @@ packages:
source: hosted
version: "3.1.0"
sdks:
dart: ">=2.15.0 <3.0.0"
dart: ">=2.14.0 <3.0.0"
flutter: ">=2.5.0"
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.1.2+8
version: 1.1.3+9

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down
23 changes: 21 additions & 2 deletions lib/src/modules/image_viewer/views/image_viewer_view.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';
import 'package:v_chat_sdk/src/modules/rooms/cubit/room_cubit.dart';

class ImageViewerView extends StatelessWidget {
class ImageViewerView extends StatefulWidget {
final String url;

const ImageViewerView(this.url, {Key? key}) : super(key: key);

@override
State<ImageViewerView> createState() => _ImageViewerViewState();
}

class _ImageViewerViewState extends State<ImageViewerView> {
@override
void initState() {
super.initState();
RoomCubit.instance.isOpenMessageImageOrVideo = true;
}

@override
void dispose() {
RoomCubit.instance.isOpenMessageImageOrVideo = false;
super.dispose();
}

@override
Widget build(BuildContext context) {
FocusScope.of(context).unfocus();
final isRtl = Directionality.of(context).index == 0;
FocusScope.of(context).unfocus();
return SafeArea(
child: Stack(
fit: StackFit.expand,
children: [
PhotoView(
imageProvider: NetworkImage(url),
imageProvider: NetworkImage(widget.url),
),
if (isRtl)
Positioned(
Expand Down
1 change: 0 additions & 1 deletion lib/src/modules/message/cubit/message_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ class MessageCubit extends Cubit<MessageState> with WidgetsBindingObserver {
if (isEmitTyping) {
emitTypingChange(0);
}
// Helpers.vlog("close for cubit called room Id $roomId ${DateTime.now()}");
super.close();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class MessageImageItem extends StatelessWidget {
constraints: const BoxConstraints(maxHeight: 500),
height: double.parse(_message.messageAttachment!.height!),
width: double.parse(_message.messageAttachment!.width!),
color: Colors.grey[300],
color: Theme.of(context).brightness == Brightness.dark
? Colors.black26
: Colors.grey[300],
child: CachedNetworkImage(
imageUrl: VChatConfig.messagesMediaBaseUrl +
_message.messageAttachment!.imageUrl.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class MessageVideoItem extends StatelessWidget {
width: double.parse(att.width!),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Colors.grey,
color: Theme.of(context).brightness == Brightness.dark
? Colors.black26
: Colors.grey[300],
),
child: Stack(
alignment: Alignment.center,
Expand Down
3 changes: 2 additions & 1 deletion lib/src/modules/message/views/message_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class _MessageViewScreenState extends State<MessageViewScreen> {
builder: (context, state) {
if (state is MessageLoading) {
return const Center(
child: CircularProgressIndicator.adaptive(),);
child: CircularProgressIndicator.adaptive(),
);
}
return Builder(
builder: (c) {
Expand Down
2 changes: 2 additions & 0 deletions lib/src/modules/rooms/cubit/room_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class RoomCubit extends Cubit<RoomState> {
final scrollController = ScrollController();
String? currentRoomId;

bool isOpenMessageImageOrVideo = false;

void getInstance() {}

Future getRoomsFromLocal() async {
Expand Down
14 changes: 14 additions & 0 deletions lib/src/modules/video_player/views/video_player_view.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:v_chat_sdk/src/modules/rooms/cubit/room_cubit.dart';
import 'package:video_player/video_player.dart' as vd;
import 'package:video_viewer/video_viewer.dart';

Expand All @@ -15,6 +16,19 @@ class _VideoPlayerViewState extends State<VideoPlayerView> {
late vd.VideoPlayerController videoPlayerController;
bool isLoading = true;

@override
void initState() {
super.initState();
RoomCubit.instance.isOpenMessageImageOrVideo = true;
}

@override
void dispose() {
RoomCubit.instance.isOpenMessageImageOrVideo = false;
videoPlayerController.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
FocusScope.of(context).unfocus();
Expand Down
Loading

0 comments on commit 2eca2c6

Please sign in to comment.