childrenProfile.dart 54.9 KB
Newer Older
1 2 3
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
4 5 6 7 8
import 'package:mobile_application_kids/progressReport.dart';
import 'package:mobile_application_kids/teacherchat.dart';
import 'package:mobile_application_kids/classroomview.dart';
import 'package:mobile_application_kids/addclassroom.dart';
import 'package:mobile_application_kids/teacherhome.dart';
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
9
import 'package:url_launcher/url_launcher.dart';
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
10

Uditha Prabhasha 's avatar
Uditha Prabhasha committed
11
import 'ActivitiesView.dart';
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
12 13
import 'ChatScreen.dart';
import 'TeacherProfile.dart';
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
14
import 'kidsReportView.dart';
15 16 17

class ChildrenProfilePage extends StatelessWidget {
  late User? user;
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
18
  late final Stream<QuerySnapshot> _usersStream, _usersStream2;
19
  int _age = 10;
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
20
  String role = '';
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
21
  late final userDetails;
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
22 23 24
  ChildrenProfilePage(document, role) {
    print(role);
    this.role = role;
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
25
    this.userDetails = document;
26 27
    user = FirebaseAuth.instance.currentUser;
    initializeStreams();
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
28
    calculateAge(userDetails['Birthday']);
29 30 31 32 33 34 35
  }

  void initializeStreams() {
    _usersStream = FirebaseFirestore.instance
        .collection('classroom')
        .where('userId', isEqualTo: user?.uid)
        .snapshots();
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
36 37 38 39 40

    _usersStream2 = FirebaseFirestore.instance
        .collection('students')
        .where('user', isEqualTo: user?.uid)
        .snapshots();
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
  }

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () async {
        // Disable the back button press
        return false;
      },
      child: Scaffold(
        appBar: AppBar(
          leading: IconButton(
            icon: Icon(Icons.arrow_back),
            onPressed: () {
              Navigator.of(context).pop();
            },
          ),
          actions: [
            Text(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
60
              'Children     ',
61 62 63 64 65 66 67 68 69 70 71
              style: TextStyle(
                color: Color(0xFF554994),
                fontSize: 24,
                fontFamily: 'Poppins',
                fontWeight: FontWeight.w700,
                height: 0.04,
                letterSpacing: -0.96,
              ),
            )
          ],
        ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
72
        body: SingleChildScrollView(
73 74 75 76 77
          padding: const EdgeInsets.all(16.0),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
78 79
                userDetails['className'],
                // 'Bright Sparkle ',
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
                style: TextStyle(
                  color: Color(0xFF11324D),
                  fontSize: 24,
                  fontFamily: 'Poppins',
                  fontWeight: FontWeight.w500,
                  height: 0.04,
                  letterSpacing: -0.96,
                ),
              ),
              Padding(
                  padding: const EdgeInsets.fromLTRB(5, 40, 5, 5),
                  child: Container(
                      width: 358,
                      height: 255,
                      decoration: ShapeDecoration(
                        color: Colors.white,
                        shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.circular(13.64),
                        ),
                        shadows: [
                          BoxShadow(
                            color: Color(0x0C000000),
                            blurRadius: 181.84,
                            offset: Offset(0, 4.55),
                            spreadRadius: 0,
                          )
                        ],
                      ),
                      child: SingleChildScrollView(
                        child: Column(
                          mainAxisSize: MainAxisSize.min,
                          mainAxisAlignment: MainAxisAlignment.start,
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            SingleChildScrollView(
                              child: Column(
                                mainAxisSize: MainAxisSize.min,
                                mainAxisAlignment: MainAxisAlignment.center,
                                crossAxisAlignment: CrossAxisAlignment.center,
                                children: [
                                  Padding(
                                    padding:
                                        const EdgeInsets.fromLTRB(0, 10, 0, 0),
                                    child: Container(
                                      width: 84,
                                      height: 84,
                                      decoration: ShapeDecoration(
                                        image: DecorationImage(
                                          image: AssetImage(
                                              "lib/assets/Ellipse 8.png"),
                                          fit: BoxFit.fill,
                                        ),
                                        shape: OvalBorder(),
                                      ),
                                    ),
                                  ),
                                  const SizedBox(height: 11),
                                  Container(
                                    width: double.infinity,
                                    height: 20,
                                    padding: const EdgeInsets.only(
                                        left: 45, right: 43),
                                    child: Row(
                                      mainAxisSize: MainAxisSize.min,
                                      mainAxisAlignment:
                                          MainAxisAlignment.center,
                                      crossAxisAlignment:
                                          CrossAxisAlignment.center,
                                      children: [
                                        Container(
                                          width: 124,
                                          height: double.infinity,
                                          child: Row(
                                            mainAxisSize: MainAxisSize.min,
                                            mainAxisAlignment:
                                                MainAxisAlignment.center,
                                            crossAxisAlignment:
                                                CrossAxisAlignment.start,
                                            children: [
                                              Text(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
160
                                                userDetails['Firstname'],
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
                                                style: TextStyle(
                                                  color: Color(0xFF11324D),
                                                  fontSize: 20,
                                                  fontFamily: 'Poppins',
                                                  fontWeight: FontWeight.w500,
                                                  height: 0.06,
                                                  letterSpacing: -0.80,
                                                ),
                                              ),
                                              const SizedBox(width: 3),
                                              Container(
                                                width: 7,
                                                height: 7,
                                                decoration: ShapeDecoration(
                                                  color: Color(0xFF00E332),
                                                  shape: OvalBorder(),
                                                ),
                                              ),
                                            ],
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                  const SizedBox(height: 11),
                                  Text(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
187
                                    userDetails['role'],
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
                                    style: TextStyle(
                                      color: Color(0xFF21205B),
                                      fontSize: 14,
                                      fontFamily: 'Poppins',
                                      fontWeight: FontWeight.w500,
                                      height: 0.07,
                                    ),
                                  ),
                                  const SizedBox(height: 11),
                                  Padding(
                                    padding: const EdgeInsets.all(8.0),
                                    child: Container(
                                      width: double.infinity,
                                      child: Row(
                                        mainAxisSize: MainAxisSize.min,
                                        mainAxisAlignment:
                                            MainAxisAlignment.start,
                                        crossAxisAlignment:
                                            CrossAxisAlignment.start,
                                        children: [
                                          Text.rich(
                                            TextSpan(
                                              children: [
                                                TextSpan(
                                                  text: 'Age',
                                                  style: TextStyle(
                                                    color: Color(0xFF21205B),
                                                    fontSize: 14,
                                                    fontFamily: 'Poppins',
                                                    fontWeight: FontWeight.w400,
                                                  ),
                                                ),
                                                TextSpan(
                                                  text: ' : ',
                                                  style: TextStyle(
                                                    color: Color(0xFF21205B),
                                                    fontSize: 14,
                                                    fontFamily: 'Poppins',
                                                    fontWeight: FontWeight.w500,
                                                  ),
                                                ),
                                                TextSpan(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
230
                                                  text: _age.toString(),
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
                                                  style: TextStyle(
                                                    color: Color(0xFF21205B),
                                                    fontSize: 14,
                                                    fontFamily: 'Poppins',
                                                    fontWeight: FontWeight.w600,
                                                  ),
                                                ),
                                              ],
                                            ),
                                          ),
                                          const SizedBox(width: 17),
                                          Text.rich(
                                            TextSpan(
                                              children: [
                                                TextSpan(
                                                  text: 'Birthday',
                                                  style: TextStyle(
                                                    color: Color(0xFF21205B),
                                                    fontSize: 14,
                                                    fontFamily: 'Poppins',
                                                    fontWeight: FontWeight.w400,
                                                  ),
                                                ),
                                                TextSpan(
                                                  text: ' :  ',
                                                  style: TextStyle(
                                                    color: Color(0xFF21205B),
                                                    fontSize: 14,
                                                    fontFamily: 'Poppins',
                                                    fontWeight: FontWeight.w500,
                                                  ),
                                                ),
                                                TextSpan(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
264
                                                  text: userDetails['Birthday'],
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
                                                  style: TextStyle(
                                                    color: Color(0xFF21205B),
                                                    fontSize: 14,
                                                    fontFamily: 'Poppins',
                                                    fontWeight: FontWeight.w600,
                                                  ),
                                                ),
                                              ],
                                            ),
                                          ),
                                          const SizedBox(width: 17),
                                          Text.rich(
                                            TextSpan(
                                              children: [
                                                TextSpan(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
280
                                                  text: 'Sex',
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
                                                  style: TextStyle(
                                                    color: Color(0xFF21205B),
                                                    fontSize: 14,
                                                    fontFamily: 'Poppins',
                                                    fontWeight: FontWeight.w400,
                                                  ),
                                                ),
                                                TextSpan(
                                                  text: ' : ',
                                                  style: TextStyle(
                                                    color: Color(0xFF21205B),
                                                    fontSize: 14,
                                                    fontFamily: 'Poppins',
                                                    fontWeight: FontWeight.w500,
                                                  ),
                                                ),
                                                TextSpan(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
298
                                                  text: userDetails['Sex'],
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
                                                  style: TextStyle(
                                                    color: Color(0xFF21205B),
                                                    fontSize: 14,
                                                    fontFamily: 'Poppins',
                                                    fontWeight: FontWeight.w600,
                                                  ),
                                                ),
                                              ],
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                  ),
                                  Padding(
                                    padding: const EdgeInsets.fromLTRB(
                                        50, 20, 40, 0),
                                    child: Container(
                                      width: 302,
                                      height: 37,
                                      child: Row(
                                        mainAxisSize: MainAxisSize.min,
                                        mainAxisAlignment:
                                            MainAxisAlignment.start,
                                        crossAxisAlignment:
                                            CrossAxisAlignment.start,
                                        children: [
                                          Container(
                                            padding: const EdgeInsets.only(
                                              top: 12,
                                              left: 10,
                                              bottom: 11.63,
                                            ),
                                            decoration: ShapeDecoration(
                                              color: Colors.white,
                                              shape: RoundedRectangleBorder(
                                                  borderRadius:
                                                      BorderRadius.circular(6)),
                                              shadows: [
                                                BoxShadow(
                                                  color: Color(0x3F000000),
                                                  blurRadius: 4,
                                                  offset: Offset(0, 1),
                                                  spreadRadius: 0,
                                                )
                                              ],
                                            ),
                                            child: Center(
                                              child: Row(
                                                mainAxisSize: MainAxisSize.min,
                                                mainAxisAlignment:
                                                    MainAxisAlignment.center,
                                                crossAxisAlignment:
                                                    CrossAxisAlignment.center,
                                                children: [
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
                                                  GestureDetector(
                                                    onTap: () {
                                                      Navigator.push(
                                                        context,
                                                        MaterialPageRoute(
                                                            builder: (context) =>
                                                                ChatScreen()),
                                                      );
                                                    },
                                                    child: Container(
                                                      height: double.infinity,
                                                      child: Row(
                                                        mainAxisSize:
                                                            MainAxisSize.min,
                                                        mainAxisAlignment:
                                                            MainAxisAlignment
                                                                .start,
                                                        crossAxisAlignment:
                                                            CrossAxisAlignment
                                                                .center,
                                                        children: [
                                                          Icon(
                                                            Icons.chat,
                                                            color:
                                                                Colors.black26,
379
                                                          ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
                                                          Text(
                                                            'Chat',
                                                            style: TextStyle(
                                                              color:
                                                                  Colors.black,
                                                              fontSize: 12,
                                                              fontFamily:
                                                                  'Poppins',
                                                              fontWeight:
                                                                  FontWeight
                                                                      .w400,
                                                              height: 0.08,
                                                            ),
                                                          ),
                                                          const SizedBox(
                                                              width: 10),
                                                        ],
                                                      ),
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
                                                    ),
                                                  ),
                                                ],
                                              ),
                                            ),
                                          ),
                                          const SizedBox(width: 16),
                                          Container(
                                            padding: const EdgeInsets.only(
                                              top: 12,
                                              left: 10,
                                              bottom: 11.63,
                                            ),
                                            decoration: ShapeDecoration(
                                              color: Colors.white,
                                              shape: RoundedRectangleBorder(
                                                  borderRadius:
                                                      BorderRadius.circular(6)),
                                              shadows: [
                                                BoxShadow(
                                                  color: Color(0x3F000000),
                                                  blurRadius: 4,
                                                  offset: Offset(0, 1),
                                                  spreadRadius: 0,
                                                )
                                              ],
                                            ),
                                            child: Row(
                                              mainAxisSize: MainAxisSize.min,
                                              mainAxisAlignment:
                                                  MainAxisAlignment.center,
                                              crossAxisAlignment:
                                                  CrossAxisAlignment.center,
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447
                                              // children: [
                                              //   GestureDetector(
                                              //     onTap: () {
                                              //       _getPhoneNumber(user?.uid);
                                              //     },
                                              //     child: Container(
                                              //       height: double.infinity,
                                              //       child: Row(
                                              //         mainAxisSize:
                                              //             MainAxisSize.min,
                                              //         mainAxisAlignment:
                                              //             MainAxisAlignment
                                              //                 .start,
                                              //         crossAxisAlignment:
                                              //             CrossAxisAlignment
                                              //                 .center,

448
                                              children: [
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
449
                                                GestureDetector(
450 451
                                                  onTap: () => _getPhoneNumber(
                                                      context, user?.uid),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
452 453 454 455 456 457 458 459 460 461 462
                                                  child: Container(
                                                    height: double.infinity,
                                                    child: Row(
                                                      mainAxisSize:
                                                          MainAxisSize.min,
                                                      mainAxisAlignment:
                                                          MainAxisAlignment
                                                              .start,
                                                      crossAxisAlignment:
                                                          CrossAxisAlignment
                                                              .center,
463
                                                              
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
464 465 466 467
                                                      children: [
                                                        Icon(
                                                          Icons.call,
                                                          color: Colors.black26,
468
                                                        ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
                                                        Text(
                                                          'Call',
                                                          style: TextStyle(
                                                            color: Colors.black,
                                                            fontSize: 12,
                                                            fontFamily:
                                                                'Poppins',
                                                            fontWeight:
                                                                FontWeight.w400,
                                                            height: 0.08,
                                                          ),
                                                        ),
                                                        const SizedBox(
                                                            width: 10),
                                                      ],
                                                    ),
485 486 487 488 489 490
                                                  ),
                                                ),
                                              ],
                                            ),
                                          ),
                                          const SizedBox(width: 16),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542
                                          GestureDetector(
                                            onTap: () {
                                              Navigator.push(
                                                context,
                                                MaterialPageRoute(
                                                    builder: (context) =>
                                                        UserActivitiesScreen(
                                                            userId: user!.uid)),
                                              );
                                            },
                                            child: Container(
                                              padding: const EdgeInsets.only(
                                                top: 11,
                                                bottom: 12,
                                              ),
                                              decoration: ShapeDecoration(
                                                color: Colors.white,
                                                shape: RoundedRectangleBorder(
                                                    borderRadius:
                                                        BorderRadius.circular(
                                                            6)),
                                                shadows: [
                                                  BoxShadow(
                                                    color: Color(0x3F000000),
                                                    blurRadius: 4,
                                                    offset: Offset(0, 1),
                                                    spreadRadius: 0,
                                                  )
                                                ],
                                              ),
                                              child: Row(
                                                mainAxisSize: MainAxisSize.min,
                                                mainAxisAlignment:
                                                    MainAxisAlignment.center,
                                                crossAxisAlignment:
                                                    CrossAxisAlignment.center,
                                                children: [
                                                  Container(
                                                    height: double.infinity,
                                                    child: Row(
                                                      mainAxisSize:
                                                          MainAxisSize.min,
                                                      mainAxisAlignment:
                                                          MainAxisAlignment
                                                              .center,
                                                      crossAxisAlignment:
                                                          CrossAxisAlignment
                                                              .center,
                                                      children: [
                                                        Icon(
                                                          Icons.book,
                                                          color: Colors.black26,
543
                                                        ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558
                                                        Text(
                                                          'Activites',
                                                          style: TextStyle(
                                                            color: Colors.black,
                                                            fontSize: 12,
                                                            fontFamily:
                                                                'Poppins',
                                                            fontWeight:
                                                                FontWeight.w400,
                                                          ),
                                                        ),
                                                        const SizedBox(
                                                            width: 10),
                                                      ],
                                                    ),
559
                                                  ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
560 561
                                                ],
                                              ),
562 563 564 565 566 567 568 569 570 571 572 573
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                  )
                                ],
                              ),
                            ),
                          ],
                        ),
                      ))),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
574
              Padding(
575 576
                padding: const EdgeInsets.fromLTRB(8, 30, 0, 0),
                child: SingleChildScrollView(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
577 578 579 580 581
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
582 583
                      role == "P"
                          ? Container(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
584
                              width: 359,
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
585 586
                              height: 178,
                              child: Column(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
587 588
                                mainAxisSize: MainAxisSize.min,
                                mainAxisAlignment: MainAxisAlignment.start,
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
589
                                crossAxisAlignment: CrossAxisAlignment.center,
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
590 591
                                children: [
                                  Container(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
592 593 594
                                    width: 359,
                                    height: 128,
                                    clipBehavior: Clip.antiAlias,
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
595
                                    decoration: ShapeDecoration(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
596 597 598 599 600
                                      image: DecorationImage(
                                        image:
                                            AssetImage("lib/assets/banner.png"),
                                        fit: BoxFit.cover,
                                      ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
601
                                      shape: RoundedRectangleBorder(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
602 603
                                        borderRadius: BorderRadius.circular(10),
                                      ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
604 605
                                      shadows: [
                                        BoxShadow(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
606 607 608
                                          color: Color(0x19000000),
                                          blurRadius: 20,
                                          offset: Offset(0, 2),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
609 610 611
                                          spreadRadius: 0,
                                        )
                                      ],
612
                                    ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
613
                                  ),
614
                                  const SizedBox(height: 8),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
615
                                  Container(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
616 617 618
                                    child: Row(
                                      mainAxisSize: MainAxisSize.min,
                                      mainAxisAlignment:
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
619
                                          MainAxisAlignment.start,
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
620
                                      crossAxisAlignment:
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
621
                                          CrossAxisAlignment.start,
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
622
                                      children: [
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
623 624
                                        Container(
                                          padding: const EdgeInsets.symmetric(
625
                                              horizontal: 40, vertical: 18), //play game button
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657
                                          decoration: ShapeDecoration(
                                            color: Color(0xFF48B62C),
                                            shape: RoundedRectangleBorder(
                                                borderRadius:
                                                    BorderRadius.circular(4)),
                                            shadows: [
                                              BoxShadow(
                                                color: Color(0x3F000000),
                                                blurRadius: 4,
                                                offset: Offset(0, 1),
                                                spreadRadius: 0,
                                              )
                                            ],
                                          ),
                                          child: Row(
                                            mainAxisSize: MainAxisSize.min,
                                            mainAxisAlignment:
                                                MainAxisAlignment.center,
                                            crossAxisAlignment:
                                                CrossAxisAlignment.center,
                                            children: [
                                              Text(
                                                'Play Here ',
                                                style: TextStyle(
                                                  color: Colors.white,
                                                  fontSize: 14,
                                                  fontFamily: 'Poppins',
                                                  fontWeight: FontWeight.w600,
                                                  height: 0.06,
                                                ),
                                              ),
                                            ],
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
658
                                          ),
659
                                        ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
660
                                      ],
661
                                    ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
662 663
                                  ),
                                ],
664
                              ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
665 666
                            )
                          : Container(),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
667 668 669 670 671 672 673 674 675 676 677 678 679 680
                      SizedBox(
                        height: 10,
                      ),
                      Text(
                        'Report',
                        style: TextStyle(
                          color: Color(0xFF21205B),
                          fontSize: 16,
                          fontFamily: 'Poppins',
                          fontWeight: FontWeight.w500,
                          height: 0.06,
                        ),
                      ),
                      const SizedBox(height: 20),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699
                      Padding(
                        padding: EdgeInsets.only(
                            left: MediaQuery.of(context).size.width * 0.04),
                        child: SingleChildScrollView(
                          child: Row(
                            mainAxisSize: MainAxisSize.min,
                            mainAxisAlignment: MainAxisAlignment.start,
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              GestureDetector(
                                onTap: () {
                                  Navigator.push(
                                    context,
                                    MaterialPageRoute(
                                        builder: (context) =>
                                            ReportKidsViewPage(
                                                sid: userDetails.id)),
                                  );
                                },
700
child: Container(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718
                                  width:
                                      MediaQuery.of(context).size.width * 0.4,
                                  height: 135,
                                  child: Stack(
                                    children: [
                                      Positioned(
                                        left: 0,
                                        top: 0,
                                        child: Container(
                                          width:
                                              MediaQuery.of(context).size.width,
                                          height: 135,
                                          decoration: ShapeDecoration(
                                            color: Color(0xFFF1EFFF),
                                            shape: RoundedRectangleBorder(
                                              borderRadius:
                                                  BorderRadius.circular(8.44),
                                            ),
719 720 721
                                          ),
                                        ),
                                      ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
722 723 724 725 726 727 728 729 730 731 732 733 734 735 736
                                      Positioned(
                                        left: 16,
                                        top: 17,
                                        child: Container(
                                          width: 119.18,
                                          height: 100.88,
                                          child: Column(
                                            mainAxisSize: MainAxisSize.min,
                                            mainAxisAlignment:
                                                MainAxisAlignment.start,
                                            crossAxisAlignment:
                                                CrossAxisAlignment.start,
                                            children: [
                                              Padding(
                                                padding:
737
                                                    const EdgeInsets.fromLTRB(0, 0, 0, 5),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
738 739 740 741 742 743 744
                                                child: Container(
                                                  width: 16.88,
                                                  height: 16.88,
                                                  clipBehavior: Clip.antiAlias,
                                                  decoration: BoxDecoration(),
                                                  child: Stack(children: [
                                                    Icon(
745
                                                      Icons.person_3,
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
746 747 748 749
                                                      color: Colors.black26,
                                                    ),
                                                  ]),
                                                ),
750
                                              ),
751
                                              const SizedBox(height: 0),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
752 753 754 755 756 757
                                              SizedBox(
                                                width: 119.18,
                                                child: Text.rich(
                                                  TextSpan(
                                                    children: [
                                                      TextSpan(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
758
                                                        text: 'Monthly progress report \n',
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
759 760 761 762
                                                        style: TextStyle(
                                                          color:
                                                              Color(0xFF403572),
                                                          fontSize: 14,
763
                                                          fontFamily: 'poppins',
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
764 765
                                                          fontWeight:
                                                              FontWeight.w500,
766 767
                                                              // letterSpacing: 0.08,
                                                          height: 0.9,
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
768
                                                        ),
769
                                                      ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
770 771
                                                    ],
                                                  ),
772 773
                                                ),
                                              ),
774
                                              const SizedBox(height: 1),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
775 776 777 778 779
                                              SizedBox(
                                                width: 119.18,
                                                child: Opacity(
                                                  opacity: 0.70,
                                                  child: Text(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
780
                                                    "Progress of kid's learning and behavior.",
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
781 782
                                                    style: TextStyle(
                                                      color: Color(0xFF8DAEAE),
783 784
                                                      fontSize: 9.55,
                                                      fontFamily: 'poppins',
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
785 786 787 788
                                                      fontWeight:
                                                          FontWeight.w400,
                                                      height: 0,
                                                    ),
789 790 791
                                                  ),
                                                ),
                                              ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
792 793
                                            ],
                                          ),
794 795
                                        ),
                                      ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
796 797
                                    ],
                                  ),
798 799
                                ),
                              ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827
                              SizedBox(
                                width: 10,
                              ),
                              GestureDetector(
                                onTap: () {
                                  Navigator.push(
                                      context,
                                      MaterialPageRoute(
                                          builder: (context) =>
                                              progressReport()));
                                },
                                child: Container(
                                  width: 150,
                                  height: 135,
                                  child: Stack(
                                    children: [
                                      Positioned(
                                        left: 0,
                                        top: 0,
                                        child: Container(
                                          width: 170,
                                          height: 135,
                                          decoration: ShapeDecoration(
                                            color: Color(0xFFC4F3F3),
                                            shape: RoundedRectangleBorder(
                                              borderRadius:
                                                  BorderRadius.circular(8.44),
                                            ),
828 829 830
                                          ),
                                        ),
                                      ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
831 832 833 834 835 836 837 838 839 840 841 842 843 844 845
                                      Positioned(
                                        left: 16,
                                        top: 17,
                                        child: Container(
                                          width: 119.18,
                                          height: 100.88,
                                          child: Column(
                                            mainAxisSize: MainAxisSize.min,
                                            mainAxisAlignment:
                                                MainAxisAlignment.start,
                                            crossAxisAlignment:
                                                CrossAxisAlignment.start,
                                            children: [
                                              Padding(
                                                padding:
846
                                                    const EdgeInsets.fromLTRB(0, 0, 0, 5),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
847 848 849 850 851 852 853
                                                child: Container(
                                                  width: 16.88,
                                                  height: 16.88,
                                                  clipBehavior: Clip.antiAlias,
                                                  decoration: BoxDecoration(),
                                                  child: Stack(children: [
                                                    Icon(
854
                                                      Icons.calendar_month,
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
855 856 857 858
                                                      color: Colors.black26,
                                                    ),
                                                  ]),
                                                ),
859
                                              ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
860 861 862 863 864 865 866
                                              const SizedBox(height: 1),
                                              SizedBox(
                                                width: 119.18,
                                                child: Text.rich(
                                                  TextSpan(
                                                    children: [
                                                      TextSpan(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
867
                                                        text: 'Monthly \nPsychology Report \n ',
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
868 869 870 871
                                                        style: TextStyle(
                                                          color:
                                                              Color(0xFF479696),
                                                          fontSize: 14,
872
                                                          fontFamily: 'Poppins',
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
873 874
                                                          fontWeight:
                                                              FontWeight.w500,
875
                                                          height: 0.9,
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
876
                                                        ),
877
                                                      ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
878 879
                                                    ],
                                                  ),
880 881
                                                ),
                                              ),
882
                                              const SizedBox(height: 1),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
883 884 885 886 887
                                              SizedBox(
                                                width: 119.18,
                                                child: Opacity(
                                                  opacity: 0.70,
                                                  child: Text(
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
888
                                                    'Monthly insights of  activity reports',
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
889 890
                                                    style: TextStyle(
                                                      color: Color(0xFF8DAEAE),
891 892
                                                      fontSize: 9.55,
                                                      fontFamily: 'poppins',
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
893 894 895 896
                                                      fontWeight:
                                                          FontWeight.w400,
                                                      height: 0,
                                                    ),
897 898 899
                                                  ),
                                                ),
                                              ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
900 901
                                            ],
                                          ),
902 903
                                        ),
                                      ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
904 905
                                    ],
                                  ),
906 907
                                ),
                              ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
908 909
                            ],
                          ),
910
                        ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
911 912
                      ),
                    ],
913 914
                  ),
                ),
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
915
              )
916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936
            ],
          ),
        ),
        bottomNavigationBar: BottomNavigationBar(
          items: const [
            BottomNavigationBarItem(
              icon: Icon(Icons.home),
              label: 'Home',
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.chat),
              label: 'Chat',
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.person),
              label: 'Profile',
            ),
          ],
          selectedItemColor: Colors.blue,
          onTap: (index) {
            // Handle bottom navigation item tap
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
937 938 939 940 941 942
            if (index == 0) {
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => TeacherHomePage()),
              );
            }
943 944 945
            if (index == 1) {
              Navigator.push(
                context,
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
946 947 948 949 950 951 952 953
                MaterialPageRoute(builder: (context) => ChatScreen()),
              );
            }
            if (index == 2) {
              Navigator.push(
                context,
                MaterialPageRoute(
                    builder: (context) => TeacherProfilePage(uid: user?.uid)),
954 955 956 957 958 959 960
              );
            }
          },
        ),
      ),
    );
  }
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
961

Uditha Prabhasha 's avatar
Uditha Prabhasha committed
962 963 964 965 966 967 968 969
  _launchPhone(url) async {
    if (await canLaunch(url)) {
      await launch(url);
    } else {
      throw 'Could not launch $url';
    }
  }

970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013
  // Future<String?> _getPhoneNumber(userUID) async {
  //   try {
  //     var snapshot = await FirebaseFirestore.instance
  //         .collection('students')
  //         .where('user', isEqualTo: userUID)
  //         .get();

  //     if (snapshot.docs.isNotEmpty) {
  //       // Assuming 'phone' is the field containing the phone number
  //       String mobile = snapshot.docs.first['Parentphone'];
  //       final url = 'tel:$mobile';
  //       _launchPhone(url);
  //     } else {
  //       return null; // Document not found
  //     }
  //   } catch (e) {
  //     print("Error getting phone number: $e");
  //     return null;
  //   }
  // }

Future<void> _makePhoneCall(BuildContext context, String phoneNumber) async {
    final Uri phoneUri = Uri(scheme: 'tel', path: phoneNumber);
    try {
      print(await canLaunchUrl(phoneUri));
      if (await canLaunchUrl(phoneUri)) {
        print('Can launch $phoneUri');
        await launchUrl(phoneUri);
        print('Launched $phoneUri');
      } else {
        print('Cannot launch $phoneUri');
        ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(content: Text('Could not launch $phoneUri')),
        );
      }
    } catch (e) {
      print('Exception caught: $e');
      ScaffoldMessenger.of(context).showSnackBar(
        SnackBar(content: Text('Error: $e')),
      );
    }
  }

Future<String?> _getPhoneNumber(context, userUID) async {
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
1014 1015 1016 1017 1018
    try {
      var snapshot = await FirebaseFirestore.instance
          .collection('students')
          .where('user', isEqualTo: userUID)
          .get();
1019
      print(userUID);
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
1020 1021 1022
      if (snapshot.docs.isNotEmpty) {
        // Assuming 'phone' is the field containing the phone number
        String mobile = snapshot.docs.first['Parentphone'];
1023 1024
        print(mobile);
        _makePhoneCall(context, mobile);
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
1025 1026 1027 1028 1029 1030 1031
      } else {
        return null; // Document not found
      }
    } catch (e) {
      print("Error getting phone number: $e");
      return null;
    }
1032
    return null;
Uditha Prabhasha 's avatar
Uditha Prabhasha committed
1033 1034
  }

Uditha Prabhasha 's avatar
Uditha Prabhasha committed
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051
  void calculateAge(birthday) {
    String birthdayText = birthday.trim();
    if (birthdayText.isNotEmpty) {
      try {
        DateTime birthday = DateTime.parse(birthdayText);
        DateTime now = DateTime.now();
        Duration difference = now.difference(birthday);

        _age = (difference.inDays / 365).floor();
      } catch (e) {
        print('Invalid date format: $e');
        // Handle invalid date format
      }
    } else {
      // Handle empty input
    }
  }
1052
}