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

Enhancing UI for inviting #2228

Closed
wants to merge 2 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import 'package:graphql_flutter/graphql_flutter.dart';
import 'package:hive/hive.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:talawa/constants/constants.dart';
import 'package:talawa/custom_painters/talawa_logo.dart';
import 'package:talawa/enums/enums.dart';
import 'package:talawa/locator.dart';
import 'package:talawa/models/organization/org_info.dart';
import 'package:talawa/models/user/user_info.dart';
import 'package:talawa/services/graphql_config.dart';
import 'package:talawa/services/navigation_service.dart';
import 'package:talawa/services/size_config.dart';
import 'package:talawa/services/user_config.dart';
import 'package:talawa/utils/app_localization.dart';
import 'package:talawa/view_model/base_view_model.dart';
import 'package:talawa/view_model/lang_view_model.dart';
import 'package:talawa/widgets/custom_alert_dialog.dart';
Expand Down Expand Up @@ -169,95 +172,60 @@ class ProfilePageViewModel extends BaseModel {
/// None
void invite(BuildContext context) {
_appLanguageService.initialize();
// organization url
// final String url =
// 'https://cyberwake.github.io/applink/invite?selectLang=${_appLanguageService.appLocal.languageCode}&setUrl=${GraphqlConfig.orgURI}&selectOrg=${userConfig.currentOrg.id!}';
// QR
const String qrData =
'https://github.com/PalisadoesFoundation/talawa/releases/download/automated/app-release.apk';
print(url);
print(qrData);
showModalBottomSheet(
final String qrData =
'${GraphqlConfig.orgURI}?orgid=${userConfig.currentOrg.id!}';
showDialog(
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30),
),
),
builder: (BuildContext context) {
return ClipRRect(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30),
return Dialog(
backgroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0),
),
child: Container(
height: MediaQuery.of(context).size.height * 0.75,
decoration: const BoxDecoration(
color: Colors.white,
padding: const EdgeInsets.all(20),
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height * 0.80,
),
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
iconButton(
CustomPaint(
size: const Size(48, 48 * 1),
painter: AppLogo(),
),
() {},
),
const SizedBox(height: 20),
Text(
'${userConfig.currentOrg.name}',
style: const TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.black87,
),
),
const SizedBox(height: 20),
QrImageView(
data: qrData,
version: QrVersions.auto,
size: 200.0,
),
SizedBox(
height: SizeConfig.screenHeight! * 0.08,
),
const SizedBox(height: 20),
Text(
'Scan the QR to join ${userConfig.currentOrg.name}',
style: const TextStyle(color: Colors.black),
AppLocalizations.of(context)!.strictTranslate('JOIN'),
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black87,
),
),
SizedBox(
height: SizeConfig.screenHeight! * 0.02,
),
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// mainAxisSize: MainAxisSize.min,
// children: [
// iconButton(
// const FaIcon(
// FontAwesomeIcons.twitter,
// size: 35,
// color: Color(0xFF1DA1F2),
// ),
// () async => SocialShare.shareTwitter('Join us', url: url),
// ),
// iconButton(
// CustomPaint(
// size: const Size(
// 50,
// 50 * 1.004,
// ), //You can Replace [WIDTH] with your desired width for Custom Paint and height will be calculated automatically
// painter: WhatsappLogo(),
// ),
// () async => SocialShare.shareWhatsapp(url),
// ),
// iconButton(
// CustomPaint(
// size: Size(
// 45,
// (45 * 1).toDouble(),
// ), //You can Replace [WIDTH] with your desired width for Custom Paint and height will be calculated automatically
// painter: TelegramLogo(),
// ),
// () async => SocialShare.shareTelegram(url),
// ),
// iconButton(
// const FaIcon(
// FontAwesomeIcons.shareNodes,
// size: 30,
// color: Color(0xff40c351),
// ),
// () async => SocialShare.shareOptions(url),
// ),
// ],
// ),
const SizedBox(height: 30),

],
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
// ignore_for_file: talawa_good_doc_comments

import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:talawa/enums/enums.dart';
import 'package:talawa/services/graphql_config.dart';
import 'package:talawa/services/size_config.dart';
import 'package:talawa/utils/app_localization.dart';
import 'package:talawa/view_model/after_auth_view_models/profile_view_models/profile_page_view_model.dart';

import '../../../helpers/test_helpers.dart';
import '../../../helpers/test_locator.dart';

Expand Down Expand Up @@ -63,7 +67,7 @@ void main() {
"fake_message",
MessageType.error,
),
);
).called(1);

model.popBottomSheet();
verify(navigationService.pop());
Expand Down Expand Up @@ -97,13 +101,16 @@ void main() {
final model = ProfilePageViewModel();
model.initialize();
const String amt = "test_amt";

void mockSetter(void Function() innerFunction) {}

await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: model.dominationButton(
amt,
mockContext,
(void Function() callback) {},
mockSetter,
),
),
),
Expand All @@ -118,82 +125,53 @@ void main() {
),
);
});

testWidgets("Test logout function", (tester) async {
final mockContext = MockBuildContext();
final model = ProfilePageViewModel();
final mocknav = getAndRegisterNavigationService();
model.initialize();
await model.logout(mockContext);
await tester.pumpAndSettle();

//Ensures that naviagation service was called
verifyInteraction(mocknav, mockName: "NavigationService");
});

testWidgets('Test changeCurrency function', (WidgetTester tester) async {
// Mock data
testWidgets("Test invite method", (WidgetTester tester) async {
// final mockContext = MockBuildContext();
final model = ProfilePageViewModel();
model.initialize();
// Set up a MaterialApp for testing
await tester.pumpWidget(
MaterialApp(
home: Builder(
builder: (BuildContext context) {
return TextButton(
child: Container(),
// You might need a button to trigger the changeCurrency function
onPressed: () {
model.changeCurrency(context, (Function callback) {});
},
);
},
locale: const Locale('en'),
localizationsDelegates: [
const AppLocalizationsDelegate(isTest: true),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
home: Scaffold(
body: Builder(
builder: (BuildContext context) {
// Trigger the invite method on button press
return ElevatedButton(
key: const Key('inviteButton'),
onPressed: () => model.invite(context),
child: const Text('Invoke Invite'),
);
},
),
),
),
);
await tester.pumpAndSettle();

// Trigger the button press to invoke changeCurrency
await tester.tap(find.byType(TextButton));
await tester.pump();
// model.invite(mockContext);

await tester.tap(find.byKey(const Key('inviteButton')));
await tester.pumpAndSettle(); // Wait for animations and UI changes

expect(find.byType(Dialog), findsOneWidget);
expect(find.byType(QrImageView), findsOneWidget);
});

testWidgets('Test attachListener function', (WidgetTester tester) async {
// Mock data
testWidgets("Test logout function", (tester) async {
final mockContext = MockBuildContext();
final model = ProfilePageViewModel();
final mocknav = getAndRegisterNavigationService();
model.initialize();
final TextEditingController donationField = TextEditingController();
// Set up a MaterialApp for testing
await tester.pumpWidget(
MaterialApp(
home: Builder(
builder: (BuildContext context) {
return Material(
child: TextFormField(
controller: donationField,
),
);
},
),
),
);

// Attach the listener
model.attachListener(
(p0) => p0(),
);

// Trigger the listener by focusing on the TextFormField
await tester.tap(find.byType(TextFormField));
await tester.pump();

// Now you can check if bottomSheetHeight is updated when the field has focus
expect(model.bottomSheetHeight, 465.12000000000006);

// Trigger the listener by removing focus from the TextFormField after a delay
await tester.pump(const Duration(milliseconds: 300));
await model.logout(mockContext);
await tester.pumpAndSettle();

// Now you can check if bottomSheetHeight is updated after losing focus
expect(model.bottomSheetHeight, SizeConfig.screenHeight! * 0.68);
//Ensures that naviagation service was called
verifyInteraction(mocknav, mockName: "NavigationService");
});
});
}
Loading