Skip to content
This repository has been archived by the owner on Jul 31, 2021. It is now read-only.

Commit

Permalink
message sender, bug, allow us phone number
Browse files Browse the repository at this point in the history
  • Loading branch information
mkofdwu committed Mar 15, 2021
1 parent 21cc676 commit e0f8b2c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 29 deletions.
5 changes: 1 addition & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
// "editor.fontFamily": "Consolas, Droid Sans Mono, monospace",
// "editor.fontSize": 15,
// "workbench.colorTheme": "Default Dark+",
// "workbench.iconTheme": "vscode-icons",
"workbench.colorTheme": "Default Dark+",
}
2 changes: 1 addition & 1 deletion lib/pages/chat/controllers/message_sender.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class MessageSender {
// done creating chat, send unsent messages
for (final unsent in List.from(unsentMessages)) {
await _uploadMessageMedia(unsent);
await ChatsService.sendMessage(chat.id, firstMessage);
await ChatsService.sendMessage(chat.id, unsent);
unsentMessages.remove(unsent);
}
chat.type = ChatType.normal;
Expand Down
54 changes: 30 additions & 24 deletions lib/pages/setup/phone_number.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:tundr/pages/setup/phone_verification.dart';
import 'package:tundr/constants/my_palette.dart';
import 'package:tundr/services/users_service.dart';
import 'package:tundr/utils/show_error_dialog.dart';
import 'package:tundr/utils/show_options_dialog.dart';
import 'package:tundr/widgets/pages/scroll_down.dart';
import 'package:tundr/widgets/scroll_down_arrow.dart';

Expand All @@ -16,17 +17,21 @@ class SetupPhoneNumberPage extends StatefulWidget {
}

class _SetupPhoneNumberPageState extends State<SetupPhoneNumberPage> {
String _countryCode = '65';
bool _loading = false;

void _selectCountryCode() async {
final countryCode = await showOptionsDialog(
context: context,
options: {'(+65) Singapore': '65', '(+1) US': '1'},
);
setState(() => _countryCode = countryCode);
}

void _nextPage() async {
setState(() => _loading = true);
final phoneNumber =
Provider.of<RegistrationInfo>(context, listen: false).phoneNumber;
if (phoneNumber.length != 11) {
await showErrorDialog(context: context, title: 'Invalid phone number');
setState(() => _loading = false);
return;
}

if (await UsersService.phoneNumberExists(phoneNumber)) {
await showErrorDialog(
Expand All @@ -44,7 +49,6 @@ class _SetupPhoneNumberPageState extends State<SetupPhoneNumberPage> {
pageBuilder: (context, animation1, animation2) =>
PhoneVerificationPage(),
transitionsBuilder: (context, animation1, animation2, child) {
// ANIMATION: curved animation with set duration
return SlideTransition(
position: Tween<Offset>(
begin: Offset(0, 1),
Expand Down Expand Up @@ -104,23 +108,26 @@ class _SetupPhoneNumberPageState extends State<SetupPhoneNumberPage> {
width: width - 60,
child: Row(
children: <Widget>[
Container(
color: MyPalette.white,
height: 60,
width: 90,
child: Row(
children: <Widget>[
SizedBox(width: 5),
Icon(Icons.add, color: MyPalette.black, size: 30),
Text(
'65',
style: TextStyle(
color: MyPalette.black,
fontSize: 40,
fontWeight: FontWeight.bold,
GestureDetector(
onTap: _selectCountryCode,
child: Container(
color: MyPalette.white,
height: 60,
width: 90,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(Icons.add, color: MyPalette.black, size: 30),
Text(
_countryCode,
style: TextStyle(
color: MyPalette.black,
fontSize: 40,
fontWeight: FontWeight.bold,
),
),
),
],
],
),
),
),
SizedBox(width: 10),
Expand All @@ -147,7 +154,6 @@ class _SetupPhoneNumberPageState extends State<SetupPhoneNumberPage> {
),
),
cursorColor: MyPalette.white,
maxLength: 8,
keyboardType: TextInputType.number,
controller: TextEditingController()
..text = Provider.of<RegistrationInfo>(context,
Expand All @@ -157,7 +163,7 @@ class _SetupPhoneNumberPageState extends State<SetupPhoneNumberPage> {
onChanged: (value) {
Provider.of<RegistrationInfo>(context,
listen: false)
.phoneNumber = '+65' + value;
.phoneNumber = '+' + _countryCode + value;
},
),
),
Expand Down

0 comments on commit e0f8b2c

Please sign in to comment.