feat:mai page done

This commit is contained in:
jahongireshonqulov
2025-11-01 14:30:56 +05:00
parent 4acc409de0
commit 44878e79b3
81 changed files with 4976 additions and 244 deletions

View File

@@ -0,0 +1,9 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M16 16C14.89 16 14 16.89 14 18C14 18.5304 14.2107 19.0391 14.5858 19.4142C14.9609 19.7893 15.4696 20 16 20C16.5304 20 17.0391 19.7893 17.4142 19.4142C17.7893 19.0391 18 18.5304 18 18C18 17.4696 17.7893 16.9609 17.4142 16.5858C17.0391 16.2107 16.5304 16 16 16ZM0 0V2H2L5.6 9.59L4.24 12.04C4.09 12.32 4 12.65 4 13C4 13.5304 4.21071 14.0391 4.58579 14.4142C4.96086 14.7893 5.46957 15 6 15H18V13H6.42C6.3537 13 6.29011 12.9737 6.24322 12.9268C6.19634 12.8799 6.17 12.8163 6.17 12.75C6.17 12.7 6.18 12.66 6.2 12.63L7.1 11H14.55C15.3 11 15.96 10.58 16.3 9.97L19.88 3.5C19.95 3.34 20 3.17 20 3C20 2.73478 19.8946 2.48043 19.7071 2.29289C19.5196 2.10536 19.2652 2 19 2H4.21L3.27 0M6 16C4.89 16 4 16.89 4 18C4 18.5304 4.21071 19.0391 4.58579 19.4142C4.96086 19.7893 5.46957 20 6 20C6.53043 20 7.03914 19.7893 7.41421 19.4142C7.78929 19.0391 8 18.5304 8 18C8 17.4696 7.78929 16.9609 7.41421 16.5858C7.03914 16.2107 6.53043 16 6 16Z" fill="url(#paint0_linear_6448_12220)"/>
<defs>
<linearGradient id="paint0_linear_6448_12220" x1="10" y1="0" x2="10" y2="20" gradientUnits="userSpaceOnUse">
<stop stop-color="#FF6F00"/>
<stop offset="1" stop-color="#FFAB40"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,23 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none"
xmlns="http://www.w3.org/2000/svg">
<defs>
<!-- Full-coverage gradient from top (#FF6F00) to bottom (#FFAB40) -->
<linearGradient id="grad1" x1="12" y1="0" x2="12" y2="24" gradientUnits="userSpaceOnUse">
<stop offset="0%" stop-color="#FF6F00"/>
<stop offset="100%" stop-color="#FFAB40"/>
</linearGradient>
</defs>
<path
d="M16.25 22.5C17.2165 22.5 18 21.7165 18 20.75C18 19.7835 17.2165 19 16.25 19C15.2835 19 14.5 19.7835 14.5 20.75C14.5 21.7165 15.2835 22.5 16.25 22.5Z"
fill="url(#grad1)" />
<path
d="M8.25 22.5C9.2165 22.5 10 21.7165 10 20.75C10 19.7835 9.2165 19 8.25 19C7.2835 19 6.5 19.7835 6.5 20.75C6.5 21.7165 7.2835 22.5 8.25 22.5Z"
fill="url(#grad1)" />
<path
d="M4.84 3.94L4.64 6.39C4.6 6.86 4.97 7.25 5.44 7.25H20.75C21.17 7.25 21.52 6.93 21.55 6.51C21.68 4.74 20.33 3.3 18.56 3.3H6.27C6.17 2.86 5.97 2.44 5.66 2.09C5.16 1.56 4.46 1.25 3.74 1.25H2C1.59 1.25 1.25 1.59 1.25 2C1.25 2.41 1.59 2.75 2 2.75H3.74C4.05 2.75 4.34 2.88 4.55 3.1C4.76 3.33 4.86 3.63 4.84 3.94Z"
fill="url(#grad1)" />
<path
d="M20.5101 8.75H5.17005C4.75005 8.75 4.41005 9.07 4.37005 9.48L4.01005 13.83C3.87005 15.54 5.21005 17 6.92005 17H18.0401C19.5401 17 20.8601 15.77 20.9701 14.27L21.3001 9.6C21.3401 9.14 20.9801 8.75 20.5101 8.75Z"
fill="url(#grad1)" />
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1,14 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 23C18.0751 23 23 18.0751 23 12C23 5.92487 18.0751 1 12 1C5.92487 1 1 5.92487 1 12C1 18.0751 5.92487 23 12 23Z" fill="url(#paint0_linear_6448_12254)" stroke="url(#paint1_linear_6448_12254)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M11.1527 9.23672L15.6663 8.3335L14.7631 12.8472C14.6686 13.3202 14.4361 13.7548 14.0951 14.096C13.7541 14.4373 13.3197 14.67 12.8467 14.7648L8.33301 15.6668L9.23623 11.1532C9.331 10.6803 9.56352 10.246 9.90453 9.90502C10.2455 9.56401 10.6798 9.33149 11.1527 9.23672Z" fill="white" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<defs>
<linearGradient id="paint0_linear_6448_12254" x1="12" y1="1" x2="12" y2="23" gradientUnits="userSpaceOnUse">
<stop stop-color="#FF6F00"/>
<stop offset="1" stop-color="#FFAB40"/>
</linearGradient>
<linearGradient id="paint1_linear_6448_12254" x1="12" y1="1" x2="12" y2="23" gradientUnits="userSpaceOnUse">
<stop stop-color="#FF6F00"/>
<stop offset="1" stop-color="#FFAB40"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,9 @@
<svg width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M18.05 4.81774L12.29 0.78774C10.72 -0.31226 8.31 -0.252259 6.8 0.917741L1.79 4.82774C0.79 5.60774 0 7.20774 0 8.46774V15.3677C0 17.9177 2.07 19.9977 4.62 19.9977H15.4C17.95 19.9977 20.02 17.9277 20.02 15.3777V8.59774C20.02 7.24774 19.15 5.58774 18.05 4.81774ZM10.76 15.9977C10.76 16.4077 10.42 16.7477 10.01 16.7477C9.6 16.7477 9.26 16.4077 9.26 15.9977V12.9977C9.26 12.5877 9.6 12.2477 10.01 12.2477C10.42 12.2477 10.76 12.5877 10.76 12.9977V15.9977Z" fill="url(#paint0_linear_6478_100)"/>
<defs>
<linearGradient id="paint0_linear_6478_100" x1="10.01" y1="0" x2="10.01" y2="19.9977" gradientUnits="userSpaceOnUse">
<stop stop-color="#FF6F00"/>
<stop offset="1" stop-color="#FFAB40"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 823 B

View File

@@ -0,0 +1,14 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 12C14.7614 12 17 9.76142 17 7C17 4.23858 14.7614 2 12 2C9.23858 2 7 4.23858 7 7C7 9.76142 9.23858 12 12 12Z" fill="url(#paint0_linear_6448_12036)"/>
<path d="M12.0002 14.5C6.99016 14.5 2.91016 17.86 2.91016 22C2.91016 22.28 3.13016 22.5 3.41016 22.5H20.5902C20.8702 22.5 21.0902 22.28 21.0902 22C21.0902 17.86 17.0102 14.5 12.0002 14.5Z" fill="url(#paint1_linear_6448_12036)"/>
<defs>
<linearGradient id="paint0_linear_6448_12036" x1="12" y1="2" x2="12" y2="12" gradientUnits="userSpaceOnUse">
<stop stop-color="#FF6F00"/>
<stop offset="1" stop-color="#FFAB40"/>
</linearGradient>
<linearGradient id="paint1_linear_6448_12036" x1="12.0002" y1="14.5" x2="12.0002" y2="22.5" gradientUnits="userSpaceOnUse">
<stop stop-color="#FF6F00"/>
<stop offset="1" stop-color="#FFAB40"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 916 B

View File

@@ -0,0 +1,16 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<mask id="mask0_6459_14583" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="3" y="1" width="18" height="22">
<path d="M18.5 4H5.5C4.94772 4 4.5 4.44772 4.5 5V21C4.5 21.5523 4.94772 22 5.5 22H18.5C19.0523 22 19.5 21.5523 19.5 21V5C19.5 4.44772 19.0523 4 18.5 4Z" fill="white" stroke="white" stroke-width="2" stroke-linejoin="round"/>
<path d="M9 2V5M15 2V5" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M8 9.5H16M8 13.5H14M8 17.5H12" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</mask>
<g mask="url(#mask0_6459_14583)">
<path d="M0 0H24V24H0V0Z" fill="url(#paint0_linear_6459_14583)"/>
</g>
<defs>
<linearGradient id="paint0_linear_6459_14583" x1="12" y1="0" x2="12" y2="24" gradientUnits="userSpaceOnUse">
<stop stop-color="#FF6F00"/>
<stop offset="1" stop-color="#FFAB40"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 996 B

View File

@@ -0,0 +1,5 @@
<svg width="24" height="24" viewBox="0 0 26 26" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M18.4167 19.4998C18.9913 19.4998 19.5424 19.7281 19.9487 20.1344C20.3551 20.5408 20.5833 21.0919 20.5833 21.6665C20.5833 22.2411 20.3551 22.7922 19.9487 23.1986C19.5424 23.6049 18.9913 23.8332 18.4167 23.8332C17.842 23.8332 17.2909 23.6049 16.8846 23.1986C16.4783 22.7922 16.25 22.2411 16.25 21.6665C16.25 20.464 17.2142 19.4998 18.4167 19.4998ZM1.08333 2.1665H4.62583L5.64416 4.33317H21.6667C21.954 4.33317 22.2295 4.44731 22.4327 4.65047C22.6359 4.85364 22.75 5.12919 22.75 5.4165C22.75 5.60067 22.6958 5.78484 22.62 5.95817L18.7417 12.9673C18.3733 13.6282 17.6583 14.0832 16.8458 14.0832H8.77499L7.79999 15.849L7.76749 15.979C7.76749 16.0508 7.79603 16.1197 7.84682 16.1705C7.89761 16.2213 7.9665 16.2498 8.03833 16.2498H20.5833V18.4165H7.58333C7.00869 18.4165 6.45759 18.1882 6.05126 17.7819C5.64493 17.3756 5.41666 16.8245 5.41666 16.2498C5.41666 15.8707 5.51416 15.5132 5.67666 15.2098L7.14999 12.5557L3.24999 4.33317H1.08333V2.1665ZM7.58333 19.4998C8.15796 19.4998 8.70906 19.7281 9.11539 20.1344C9.52172 20.5408 9.74999 21.0919 9.74999 21.6665C9.74999 22.2411 9.52172 22.7922 9.11539 23.1986C8.70906 23.6049 8.15796 23.8332 7.58333 23.8332C7.00869 23.8332 6.45759 23.6049 6.05126 23.1986C5.64493 22.7922 5.41666 22.2411 5.41666 21.6665C5.41666 20.464 6.38083 19.4998 7.58333 19.4998ZM17.3333 11.9165L20.345 6.49984H6.65166L9.20833 11.9165H17.3333Z"
fill="#626262" />
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,16 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M2 2H3.74001C4.82001 2 5.67 2.93 5.58 4L4.75 13.96C4.61 15.59 5.89999 16.99 7.53999 16.99H18.19C19.63 16.99 20.89 15.81 21 14.38L21.54 6.88C21.66 5.22 20.4 3.87 18.73 3.87H5.82001"
stroke="#626262" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round"
stroke-linejoin="round" />
<path
d="M16.25 22C16.9404 22 17.5 21.4404 17.5 20.75C17.5 20.0596 16.9404 19.5 16.25 19.5C15.5596 19.5 15 20.0596 15 20.75C15 21.4404 15.5596 22 16.25 22Z"
stroke="#626262" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round"
stroke-linejoin="round" />
<path
d="M8.25 22C8.94036 22 9.5 21.4404 9.5 20.75C9.5 20.0596 8.94036 19.5 8.25 19.5C7.55964 19.5 7 20.0596 7 20.75C7 21.4404 7.55964 22 8.25 22Z"
stroke="#626262" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round"
stroke-linejoin="round" />
<path d="M9 8H21" stroke="#626262" stroke-width="1.5" stroke-miterlimit="10"
stroke-linecap="round" stroke-linejoin="round" />
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,11 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_6459_29443)">
<path d="M12 23C18.0751 23 23 18.0751 23 12C23 5.92487 18.0751 1 12 1C5.92487 1 1 5.92487 1 12C1 18.0751 5.92487 23 12 23Z" stroke="#626262" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M11.1528 9.23672L15.6665 8.3335L14.7633 12.8472C14.6687 13.3202 14.4363 13.7548 14.0953 14.096C13.7542 14.4373 13.3198 14.67 12.8468 14.7648L8.33315 15.6668L9.23638 11.1532C9.33114 10.6803 9.56366 10.246 9.90468 9.90502C10.2457 9.56401 10.68 9.33149 11.1528 9.23672Z" stroke="#626262" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</g>
<defs>
<clipPath id="clip0_6459_29443">
<rect width="24" height="24" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 822 B

View File

@@ -0,0 +1,4 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9.02 2.83992L3.63 7.03992C2.73 7.73992 2 9.22992 2 10.3599V17.7699C2 20.0899 3.89 21.9899 6.21 21.9899H17.79C20.11 21.9899 22 20.0899 22 17.7799V10.4999C22 9.28992 21.19 7.73992 20.2 7.04992L14.02 2.71992C12.62 1.73992 10.37 1.78992 9.02 2.83992Z" stroke="#626262" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M12 17.99V14.99" stroke="#626262" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 557 B

View File

@@ -0,0 +1,4 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 12C14.7614 12 17 9.76142 17 7C17 4.23858 14.7614 2 12 2C9.23858 2 7 4.23858 7 7C7 9.76142 9.23858 12 12 12Z" stroke="#626262" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M20.59 22C20.59 18.13 16.74 15 12 15C7.26003 15 3.41003 18.13 3.41003 22" stroke="#626262" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 478 B

View File

@@ -0,0 +1,4 @@
<svg width="26" height="26" viewBox="0 0 26 26" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M20.0417 4.3335H5.95833C5.36002 4.3335 4.875 4.81852 4.875 5.41683V22.7502C4.875 23.3485 5.36002 23.8335 5.95833 23.8335H20.0417C20.64 23.8335 21.125 23.3485 21.125 22.7502V5.41683C21.125 4.81852 20.64 4.3335 20.0417 4.3335Z" stroke="#626262" stroke-width="2" stroke-linejoin="round"/>
<path d="M9.74996 2.16675V5.41675M16.25 2.16675V5.41675M8.66663 10.2917H17.3333M8.66663 14.6251H15.1666M8.66663 18.9584H13" stroke="#626262" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 605 B

View File

@@ -0,0 +1,5 @@
<svg width="24" height="24" viewBox="0 0 26 26" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M18.4163 19.4998C18.991 19.4998 19.5421 19.7281 19.9484 20.1344C20.3547 20.5408 20.583 21.0919 20.583 21.6665C20.583 22.2411 20.3547 22.7922 19.9484 23.1986C19.5421 23.6049 18.991 23.8332 18.4163 23.8332C17.8417 23.8332 17.2906 23.6049 16.8843 23.1986C16.4779 22.7922 16.2497 22.2411 16.2497 21.6665C16.2497 20.464 17.2138 19.4998 18.4163 19.4998ZM1.08301 2.1665H4.62551L5.64384 4.33317H21.6663C21.9537 4.33317 22.2292 4.44731 22.4324 4.65047C22.6355 4.85364 22.7497 5.12919 22.7497 5.4165C22.7497 5.60067 22.6955 5.78484 22.6197 5.95817L18.7413 12.9673C18.373 13.6282 17.658 14.0832 16.8455 14.0832H8.77467L7.79967 15.849L7.76717 15.979C7.76717 16.0508 7.79571 16.1197 7.8465 16.1705C7.89729 16.2213 7.96618 16.2498 8.03801 16.2498H20.583V18.4165H7.58301C7.00837 18.4165 6.45727 18.1882 6.05094 17.7819C5.64461 17.3756 5.41634 16.8245 5.41634 16.2498C5.41634 15.8707 5.51384 15.5132 5.67634 15.2098L7.14967 12.5557L3.24967 4.33317H1.08301V2.1665ZM7.58301 19.4998C8.15764 19.4998 8.70874 19.7281 9.11507 20.1344C9.5214 20.5408 9.74967 21.0919 9.74967 21.6665C9.74967 22.2411 9.5214 22.7922 9.11507 23.1986C8.70874 23.6049 8.15764 23.8332 7.58301 23.8332C7.00837 23.8332 6.45727 23.6049 6.05094 23.1986C5.64461 22.7922 5.41634 22.2411 5.41634 21.6665C5.41634 20.464 6.38051 19.4998 7.58301 19.4998ZM17.333 11.9165L20.3447 6.49984H6.65134L9.20801 11.9165H17.333Z"
fill="#A9A9A9" />
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,16 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M2 2H3.74001C4.82001 2 5.67 2.93 5.58 4L4.75 13.96C4.61 15.59 5.89999 16.99 7.53999 16.99H18.19C19.63 16.99 20.89 15.81 21 14.38L21.54 6.88C21.66 5.22 20.4 3.87 18.73 3.87H5.82001"
stroke="#A9A9A9" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round"
stroke-linejoin="round" />
<path
d="M16.25 22C16.9404 22 17.5 21.4404 17.5 20.75C17.5 20.0596 16.9404 19.5 16.25 19.5C15.5596 19.5 15 20.0596 15 20.75C15 21.4404 15.5596 22 16.25 22Z"
stroke="#A9A9A9" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round"
stroke-linejoin="round" />
<path
d="M8.25 22C8.94036 22 9.5 21.4404 9.5 20.75C9.5 20.0596 8.94036 19.5 8.25 19.5C7.55964 19.5 7 20.0596 7 20.75C7 21.4404 7.55964 22 8.25 22Z"
stroke="#A9A9A9" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round"
stroke-linejoin="round" />
<path d="M9 8H21" stroke="#A9A9A9" stroke-width="1.5" stroke-miterlimit="10"
stroke-linecap="round" stroke-linejoin="round" />
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,4 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11.75 22.75C17.8251 22.75 22.75 17.8251 22.75 11.75C22.75 5.67487 17.8251 0.75 11.75 0.75C5.67487 0.75 0.75 5.67487 0.75 11.75C0.75 17.8251 5.67487 22.75 11.75 22.75Z" stroke="#A9A9A9" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M10.9027 8.98672L15.4163 8.0835L14.5131 12.5972C14.4186 13.0702 14.1861 13.5048 13.8451 13.846C13.5041 14.1873 13.0697 14.42 12.5967 14.5148L8.08301 15.4168L8.98623 10.9032C9.081 10.4303 9.31352 9.99603 9.65453 9.65502C9.99555 9.31401 10.4298 9.08149 10.9027 8.98672Z" stroke="#A9A9A9" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 729 B

View File

@@ -0,0 +1,4 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9.02 2.84016L3.63 7.04016C2.73 7.74016 2 9.23016 2 10.3602V17.7702C2 20.0902 3.89 21.9902 6.21 21.9902H17.79C20.11 21.9902 22 20.0902 22 17.7802V10.5002C22 9.29016 21.19 7.74016 20.2 7.05016L14.02 2.72016C12.62 1.74016 10.37 1.79016 9.02 2.84016Z" stroke="#A7AEC1" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M12 17.9902V14.9902" stroke="#A7AEC1" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 561 B

View File

@@ -0,0 +1,4 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 12C14.7614 12 17 9.76142 17 7C17 4.23858 14.7614 2 12 2C9.23858 2 7 4.23858 7 7C7 9.76142 9.23858 12 12 12Z" stroke="#A9A9A9" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M20.5901 22C20.5901 18.13 16.7402 15 12.0002 15C7.26015 15 3.41016 18.13 3.41016 22" stroke="#A9A9A9" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 489 B

View File

@@ -0,0 +1,4 @@
<svg width="26" height="26" viewBox="0 0 26 26" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M20.0417 4.33301H5.95833C5.36002 4.33301 4.875 4.81803 4.875 5.41634V22.7497C4.875 23.348 5.36002 23.833 5.95833 23.833H20.0417C20.64 23.833 21.125 23.348 21.125 22.7497V5.41634C21.125 4.81803 20.64 4.33301 20.0417 4.33301Z" stroke="#A9A9A9" stroke-width="2" stroke-linejoin="round"/>
<path d="M9.75033 2.1665V5.4165M16.2503 2.1665V5.4165M8.66699 10.2915H17.3337M8.66699 14.6248H15.167M8.66699 18.9582H13.0003" stroke="#A9A9A9" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 606 B

View File

@@ -30,6 +30,11 @@
"google": "Google", "google": "Google",
"facebook": "Facebook", "facebook": "Facebook",
"dont_have_account": "Dont have an account?", "dont_have_account": "Dont have an account?",
"register": "Register" "register": "Register",
"home": "Home",
"discover": "Discover",
"cart": "Cart",
"transactions": "Transactions",
"profile": "Profile"
} }

View File

@@ -30,6 +30,11 @@
"google": "Google", "google": "Google",
"facebook": "Facebook", "facebook": "Facebook",
"dont_have_account": "У вас нет аккаунта?", "dont_have_account": "У вас нет аккаунта?",
"register": "Зарегистрироваться" "register": "Зарегистрироваться",
"home": "Главная",
"discover": "Обзор",
"cart": "Корзина",
"transactions": "Транзакции",
"profile": "Профиль"
} }

View File

@@ -30,6 +30,11 @@
"google": "Google", "google": "Google",
"facebook": "Facebook", "facebook": "Facebook",
"dont_have_account": "Akkauntingiz yoqmi?", "dont_have_account": "Akkauntingiz yoqmi?",
"register": "Royxatdan otish" "register": "Royxatdan otish",
"home": "Bosh sahifa",
"discover": "Kashf etish",
"cart": "Savat",
"transactions": "Tranzaksiyalar",
"profile": "Profil"
} }

View File

@@ -13,6 +13,31 @@ import 'package:dio/dio.dart' as _i361;
import 'package:get_it/get_it.dart' as _i174; import 'package:get_it/get_it.dart' as _i174;
import 'package:injectable/injectable.dart' as _i526; import 'package:injectable/injectable.dart' as _i526;
import '../../feature/auth/data/datasource/auth_datasource.dart' as _i246;
import '../../feature/auth/data/repository/auth_repository_impl.dart' as _i648;
import '../../feature/auth/domain/repository/auth_repository.dart' as _i884;
import '../../feature/auth/domain/usecases/login_usecase.dart' as _i241;
import '../../feature/auth/domain/usecases/register_usecase.dart' as _i607;
import '../../feature/auth/domain/usecases/reset_password_usecase.dart'
as _i694;
import '../../feature/auth/domain/usecases/verify_otp_code_login_usecase.dart'
as _i318;
import '../../feature/auth/domain/usecases/verify_otp_code_register_usecase.dart'
as _i406;
import '../../feature/auth/domain/usecases/verify_phone_login_usecase.dart'
as _i801;
import '../../feature/auth/domain/usecases/verify_phone_register_usecase.dart'
as _i664;
import '../../feature/auth/presentation/blocs/login_bloc/login_bloc.dart'
as _i1065;
import '../../feature/auth/presentation/blocs/register_bloc/register_bloc.dart'
as _i1050;
import '../../feature/auth/presentation/blocs/reset_password_bloc/reset_password_bloc.dart'
as _i97;
import '../../feature/auth/presentation/blocs/verify_otp_bloc/verify_otp_bloc.dart'
as _i323;
import '../../feature/auth/presentation/blocs/verify_phone_bloc/verify_phone_bloc.dart'
as _i224;
import '../../feature/common/presentation/blocs/language_bloc/language_bloc.dart' import '../../feature/common/presentation/blocs/language_bloc/language_bloc.dart'
as _i942; as _i942;
import '../../feature/main/presentation/blocs/main_bloc/main_bloc.dart' import '../../feature/main/presentation/blocs/main_bloc/main_bloc.dart'
@@ -47,6 +72,63 @@ extension GetItInjectableX on _i174.GetIt {
gh.singleton<_i354.RequestHandlerService>( gh.singleton<_i354.RequestHandlerService>(
() => _i354.RequestHandlerService(gh<_i361.Dio>()), () => _i354.RequestHandlerService(gh<_i361.Dio>()),
); );
gh.lazySingleton<_i246.AuthDatasource>(
() => _i246.AuthDatasourceImpl(gh<_i354.RequestHandlerService>()),
);
gh.lazySingleton<_i884.AuthRepository>(
() => _i648.AuthRepositoryImpl(
gh<_i354.RequestHandlerService>(),
gh<_i246.AuthDatasource>(),
),
);
gh.factory<_i607.RegisterUseCase>(
() => _i607.RegisterUseCase(gh<_i884.AuthRepository>()),
);
gh.factory<_i241.LoginUseCase>(
() => _i241.LoginUseCase(gh<_i884.AuthRepository>()),
);
gh.factory<_i694.ResetPasswordUseCase>(
() => _i694.ResetPasswordUseCase(gh<_i884.AuthRepository>()),
);
gh.factory<_i318.VerifyOtpCodeForgotPasswordUseCase>(
() =>
_i318.VerifyOtpCodeForgotPasswordUseCase(gh<_i884.AuthRepository>()),
);
gh.factory<_i801.VerifyPhoneNumberLoginUseCase>(
() => _i801.VerifyPhoneNumberLoginUseCase(gh<_i884.AuthRepository>()),
);
gh.factory<_i664.VerifyPhoneRegisterUseCase>(
() => _i664.VerifyPhoneRegisterUseCase(gh<_i884.AuthRepository>()),
);
gh.factory<_i406.VerifyOtpCodeRegisterUseCase>(
() => _i406.VerifyOtpCodeRegisterUseCase(gh<_i884.AuthRepository>()),
);
gh.factory<_i323.VerifyOtpBloc>(
() => _i323.VerifyOtpBloc(
gh<_i406.VerifyOtpCodeRegisterUseCase>(),
gh<_i318.VerifyOtpCodeForgotPasswordUseCase>(),
gh<_i664.VerifyPhoneRegisterUseCase>(),
gh<_i801.VerifyPhoneNumberLoginUseCase>(),
),
);
gh.factory<_i224.VerifyPhoneBloc>(
() => _i224.VerifyPhoneBloc(
gh<_i801.VerifyPhoneNumberLoginUseCase>(),
gh<_i664.VerifyPhoneRegisterUseCase>(),
),
);
gh.factory<_i1050.RegisterBloc>(
() => _i1050.RegisterBloc(gh<_i607.RegisterUseCase>()),
);
gh.factory<_i97.ResetPasswordBloc>(
() => _i97.ResetPasswordBloc(gh<_i694.ResetPasswordUseCase>()),
);
gh.factory<_i1065.LoginBloc>(
() => _i1065.LoginBloc(
gh<_i241.LoginUseCase>(),
gh<_i321.StorageService>(),
),
);
return this; return this;
} }
} }

View File

@@ -249,6 +249,36 @@ abstract class AppLocalizations {
/// In en, this message translates to: /// In en, this message translates to:
/// **'Register'** /// **'Register'**
String get register; String get register;
/// No description provided for @home.
///
/// In en, this message translates to:
/// **'Home'**
String get home;
/// No description provided for @discover.
///
/// In en, this message translates to:
/// **'Discover'**
String get discover;
/// No description provided for @cart.
///
/// In en, this message translates to:
/// **'Cart'**
String get cart;
/// No description provided for @transactions.
///
/// In en, this message translates to:
/// **'Transactions'**
String get transactions;
/// No description provided for @profile.
///
/// In en, this message translates to:
/// **'Profile'**
String get profile;
} }
class _AppLocalizationsDelegate class _AppLocalizationsDelegate

View File

@@ -90,4 +90,19 @@ class AppLocalizationsEn extends AppLocalizations {
@override @override
String get register => 'Register'; String get register => 'Register';
@override
String get home => 'Home';
@override
String get discover => 'Discover';
@override
String get cart => 'Cart';
@override
String get transactions => 'Transactions';
@override
String get profile => 'Profile';
} }

View File

@@ -88,4 +88,19 @@ class AppLocalizationsRu extends AppLocalizations {
@override @override
String get register => 'Зарегистрироваться'; String get register => 'Зарегистрироваться';
@override
String get home => 'Главная';
@override
String get discover => 'Обзор';
@override
String get cart => 'Корзина';
@override
String get transactions => 'Транзакции';
@override
String get profile => 'Профиль';
} }

View File

@@ -88,4 +88,19 @@ class AppLocalizationsUz extends AppLocalizations {
@override @override
String get register => 'Royxatdan otish'; String get register => 'Royxatdan otish';
@override
String get home => 'Bosh sahifa';
@override
String get discover => 'Kashf etish';
@override
String get cart => 'Savat';
@override
String get transactions => 'Tranzaksiyalar';
@override
String get profile => 'Profil';
} }

View File

@@ -1,5 +1,5 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:food_delivery_client/feature/auth/presentation/login_page/login_page.dart'; import 'package:food_delivery_client/feature/auth/presentation/pages/login_page/login_page.dart';
import 'package:food_delivery_client/feature/onboarding/presentation/pages/onboarding_page/onboarding_page.dart'; import 'package:food_delivery_client/feature/onboarding/presentation/pages/onboarding_page/onboarding_page.dart';
import 'package:food_delivery_client/feature/onboarding/presentation/pages/splash_page/splash_page.dart'; import 'package:food_delivery_client/feature/onboarding/presentation/pages/splash_page/splash_page.dart';
@@ -26,6 +26,10 @@ class AppRoutes {
path: Routes.login, path: Routes.login,
pageBuilder: (context, state) => CupertinoPage(child: LoginPage()), pageBuilder: (context, state) => CupertinoPage(child: LoginPage()),
), ),
GoRoute(
path: Routes.main,
pageBuilder: (context, state) => CupertinoPage(child: MainPage()),
),
], ],
); );
} }

View File

@@ -54,5 +54,7 @@ abstract class AppColors {
static const Color cE2E4EA = Color(0xFFE2E4EA); static const Color cE2E4EA = Color(0xFFE2E4EA);
static const Color cA7AEC1 = Color(0xFFA7AEC1); static const Color cA7AEC1 = Color(0xFFA7AEC1);
static const Color c151B33 = Color(0xFF151B33); static const Color c151B33 = Color(0xFF151B33);
static const Color cE5E7EB = Color(0xFFE5E7EB);
} }

View File

@@ -7,17 +7,34 @@ abstract class AppIcons {
static const String icLogin = "$baseUrl/ic_login.svg"; static const String icLogin = "$baseUrl/ic_login.svg";
static const String icVisibility = "$baseUrl/ic_visibility.svg"; static const String icVisibility = "$baseUrl/ic_visibility.svg";
static const String icVisibilityOff = "$baseUrl/ic_visibility_off.svg"; static const String icVisibilityOff = "$baseUrl/ic_visibility_off.svg";
static const String icHome = "$baseUrl/ic_home.svg";
static const String icDiscover = "$baseUrl/ic_discover.svg";
static const String icCart = "$baseUrl/ic_cart.svg";
static const String icCart1 = "$baseUrl/ic_cart1.svg";
static const String icTransactions = "$baseUrl/ic_transactions.svg";
static const String icProfile = "$baseUrl/ic_profile.svg";
} }
abstract class AppLightSvgs { abstract class AppLightSvgs {
static const String baseUrl = "assets/icons/light"; static const String baseUrl = "assets/icons/light";
static const String icSplash = "$baseUrl/ic_splash.svg"; static const String icSplash = "$baseUrl/ic_splash.svg";
static const String icArrowLeft = "$baseUrl/ic_arrow_left.svg"; static const String icArrowLeft = "$baseUrl/ic_arrow_left.svg";
static const String icHome = "$baseUrl/ic_home.svg";
static const String icDiscover = "$baseUrl/ic_discover.svg";
static const String icCart = "$baseUrl/ic_cart.svg";
static const String icCart1 = "$baseUrl/ic_cart1.svg";
static const String icTransactions = "$baseUrl/ic_transactions.svg";
static const String icProfile = "$baseUrl/ic_profile.svg";
} }
abstract class AppDarkSvgs { abstract class AppDarkSvgs {
static const String baseUrl = "assets/icons/dark"; static const String baseUrl = "assets/icons/dark";
static const String icSplash = "$baseUrl/ic_splash.svg"; static const String icSplash = "$baseUrl/ic_splash.svg";
static const String icArrowLeft = "$baseUrl/ic_arrow_left.svg"; static const String icArrowLeft = "$baseUrl/ic_arrow_left.svg";
static const String icHome = "$baseUrl/ic_home.svg";
static const String icDiscover = "$baseUrl/ic_discover.svg";
static const String icCart = "$baseUrl/ic_cart.svg";
static const String icCart1 = "$baseUrl/ic_cart1.svg";
static const String icTransactions = "$baseUrl/ic_transactions.svg";
static const String icProfile = "$baseUrl/ic_profile.svg";
} }

View File

@@ -46,17 +46,17 @@ abstract class AppTheme {
), ),
bottomNavigationBarTheme: BottomNavigationBarThemeData( bottomNavigationBarTheme: BottomNavigationBarThemeData(
elevation: 0, elevation: 0,
showSelectedLabels: true, showSelectedLabels: false,
showUnselectedLabels: true, showUnselectedLabels: false,
backgroundColor: AppColors.cFFFFFF, backgroundColor: AppColors.cFFFFFF,
type: BottomNavigationBarType.fixed, type: BottomNavigationBarType.fixed,
unselectedItemColor: AppColors.cB5B5B5, unselectedItemColor: AppColors.cA9A9A9,
selectedItemColor: AppColors.c000000, selectedItemColor: AppColors.cFF6F00,
selectedLabelStyle: AppTextStyles.size10Regular.copyWith( selectedLabelStyle: AppTextStyles.size12Medium.copyWith(
color: Colors.red, color: AppColors.cFF6F00,
), ),
unselectedLabelStyle: AppTextStyles.size10Regular.copyWith( unselectedLabelStyle: AppTextStyles.size10Regular.copyWith(
color: AppColors.c000000, color: AppColors.cA9A9A9,
), ),
// unselectedLabelStyle: AppTextStyles.size14Medium.copyWith( // unselectedLabelStyle: AppTextStyles.size14Medium.copyWith(
// color: AppColors.c888888, // color: AppColors.c888888,
@@ -138,17 +138,17 @@ abstract class AppTheme {
), ),
bottomNavigationBarTheme: BottomNavigationBarThemeData( bottomNavigationBarTheme: BottomNavigationBarThemeData(
elevation: 0, elevation: 0,
showSelectedLabels: true, showSelectedLabels: false,
showUnselectedLabels: true, showUnselectedLabels: false,
backgroundColor: AppColors.cFFFFFF, backgroundColor: AppColors.c131720,
type: BottomNavigationBarType.fixed, type: BottomNavigationBarType.fixed,
unselectedItemColor: AppColors.cB5B5B5, unselectedItemColor: AppColors.c626262,
selectedItemColor: AppColors.c000000, selectedItemColor: AppColors.cFF6F00,
selectedLabelStyle: AppTextStyles.size10Regular.copyWith( selectedLabelStyle: AppTextStyles.size12Medium.copyWith(
color: Colors.red, color: AppColors.cFF6F00,
), ),
unselectedLabelStyle: AppTextStyles.size10Regular.copyWith( unselectedLabelStyle: AppTextStyles.size12Medium.copyWith(
color: AppColors.c000000, color: AppColors.c626262,
), ),
// unselectedLabelStyle: AppTextStyles.size14Medium.copyWith( // unselectedLabelStyle: AppTextStyles.size14Medium.copyWith(
// color: AppColors.c888888, // color: AppColors.c888888,

View File

@@ -8,6 +8,10 @@ class AppThemeColors extends ThemeExtension<AppThemeColors> {
final Color buttonInactiveColor; final Color buttonInactiveColor;
final Color borderColor; final Color borderColor;
final Color inActiveColor; final Color inActiveColor;
final Color inActiveColor1;
final Color inActiveColor2;
AppThemeColors({ AppThemeColors({
required this.onBoardingColor, required this.onBoardingColor,
@@ -16,6 +20,9 @@ class AppThemeColors extends ThemeExtension<AppThemeColors> {
required this.buttonInactiveColor, required this.buttonInactiveColor,
required this.borderColor, required this.borderColor,
required this.inActiveColor, required this.inActiveColor,
required this.inActiveColor1,
required this.inActiveColor2,
}); });
static AppThemeColors light = AppThemeColors( static AppThemeColors light = AppThemeColors(
@@ -25,6 +32,8 @@ class AppThemeColors extends ThemeExtension<AppThemeColors> {
iconColor: AppColors.cFFFFFF, iconColor: AppColors.cFFFFFF,
borderColor: AppColors.cE2E4EA, borderColor: AppColors.cE2E4EA,
inActiveColor: AppColors.cE2E4EA, inActiveColor: AppColors.cE2E4EA,
inActiveColor1: AppColors.cA9A9A9,
inActiveColor2: AppColors.cE5E7EB
); );
static AppThemeColors dark = AppThemeColors( static AppThemeColors dark = AppThemeColors(
@@ -34,6 +43,8 @@ class AppThemeColors extends ThemeExtension<AppThemeColors> {
iconColor: AppColors.c131720, iconColor: AppColors.c131720,
borderColor: AppColors.c292F3D, borderColor: AppColors.c292F3D,
inActiveColor: AppColors.c292F3D, inActiveColor: AppColors.c292F3D,
inActiveColor1: AppColors.c626262,
inActiveColor2: AppColors.c292F3D
); );
@override @override
@@ -44,6 +55,9 @@ class AppThemeColors extends ThemeExtension<AppThemeColors> {
Color? buttonInactiveColor, Color? buttonInactiveColor,
Color? borderColor, Color? borderColor,
Color? inActiveColor, Color? inActiveColor,
Color? inActiveColor1,
Color? inActiveColor2,
}) { }) {
return AppThemeColors( return AppThemeColors(
onBoardingColor: onBoardingColor ?? this.onBoardingColor, onBoardingColor: onBoardingColor ?? this.onBoardingColor,
@@ -52,6 +66,8 @@ class AppThemeColors extends ThemeExtension<AppThemeColors> {
buttonInactiveColor: buttonInactiveColor ?? this.buttonInactiveColor, buttonInactiveColor: buttonInactiveColor ?? this.buttonInactiveColor,
borderColor: borderColor ?? this.borderColor, borderColor: borderColor ?? this.borderColor,
inActiveColor: inActiveColor ?? this.inActiveColor, inActiveColor: inActiveColor ?? this.inActiveColor,
inActiveColor1: inActiveColor1 ?? this.inActiveColor1,
inActiveColor2: inActiveColor2??this.inActiveColor2
); );
} }

View File

@@ -4,27 +4,66 @@ import 'package:food_delivery_client/core/core.dart';
class AppThemeIcons extends ThemeExtension<AppThemeIcons> { class AppThemeIcons extends ThemeExtension<AppThemeIcons> {
final String icSplash; final String icSplash;
final String icArrowLeft; final String icArrowLeft;
final String icHome;
final String icDiscover;
final String icCart;
final String icCart1;
final String icTransactions;
final String icProfile;
AppThemeIcons({required this.icSplash, required this.icArrowLeft}); AppThemeIcons({
required this.icSplash,
required this.icArrowLeft,
required this.icHome,
required this.icDiscover,
required this.icCart,
required this.icTransactions,
required this.icProfile,
required this.icCart1,
});
static AppThemeIcons light = AppThemeIcons( static AppThemeIcons light = AppThemeIcons(
icSplash: AppLightSvgs.icSplash, icSplash: AppLightSvgs.icSplash,
icArrowLeft: AppLightSvgs.icArrowLeft, icArrowLeft: AppLightSvgs.icArrowLeft,
icHome: AppLightSvgs.icHome,
icDiscover: AppLightSvgs.icDiscover,
icCart: AppLightSvgs.icCart,
icTransactions: AppLightSvgs.icTransactions,
icProfile: AppLightSvgs.icProfile,
icCart1: AppLightSvgs.icCart1,
); );
static AppThemeIcons dark = AppThemeIcons( static AppThemeIcons dark = AppThemeIcons(
icSplash: AppDarkSvgs.icSplash, icSplash: AppDarkSvgs.icSplash,
icArrowLeft: AppDarkSvgs.icArrowLeft, icArrowLeft: AppDarkSvgs.icArrowLeft,
icHome: AppDarkSvgs.icHome,
icDiscover: AppDarkSvgs.icDiscover,
icCart: AppDarkSvgs.icCart,
icTransactions: AppDarkSvgs.icTransactions,
icProfile: AppDarkSvgs.icProfile,
icCart1: AppDarkSvgs.icCart1,
); );
@override @override
ThemeExtension<AppThemeIcons> copyWith({ ThemeExtension<AppThemeIcons> copyWith({
String? icSplash, String? icSplash,
String? icArrowLeft, String? icArrowLeft,
String? icHome,
String? icDiscover,
String? icCart,
String? icCart1,
String? icTransactions,
String? icProfile,
}) { }) {
return AppThemeIcons( return AppThemeIcons(
icSplash: icSplash ?? this.icSplash, icSplash: icSplash ?? this.icSplash,
icArrowLeft: icArrowLeft ?? this.icArrowLeft, icArrowLeft: icArrowLeft ?? this.icArrowLeft,
icHome: icHome ?? this.icHome,
icDiscover: icDiscover ?? this.icDiscover,
icCart: icCart ?? this.icCart,
icTransactions: icTransactions ?? this.icTransactions,
icProfile: icProfile ?? this.icProfile,
icCart1: icCart ?? this.icCart1,
); );
} }

View File

@@ -2,8 +2,8 @@ import '../../food_delivery_client.dart';
abstract class AppUtils { abstract class AppUtils {
static const Gradient kGradient = LinearGradient( static const Gradient kGradient = LinearGradient(
begin: AlignmentGeometry.bottomCenter, end: AlignmentGeometry.bottomCenter,
end: AlignmentGeometry.topCenter, begin: AlignmentGeometry.topCenter,
colors: [AppColors.cFF6F00, AppColors.cFFAB40], colors: [AppColors.cFF6F00, AppColors.cFFAB40],
); );

View File

@@ -0,0 +1,138 @@
import 'package:food_delivery_client/core/services/request_handler_service.dart';
import 'package:food_delivery_client/feature/auth/data/models/response/login_response.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/register_usecase.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/reset_password_usecase.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_otp_code_login_usecase.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_phone_login_usecase.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
abstract class AuthDatasource {
Future<LoginResponseModel> login({
required String phoneNumber,
required String password,
});
Future<SuccessModel> verifyPhoneResetPassword({
required VerifyPhoneNumberParams params,
});
Future<SuccessModel> verifyOtpCodeResetPassword({
required VerifyOtpCodeParams params,
});
Future<SuccessModel> resetPassword({required ResetPasswordParams params});
Future<SuccessModel> verifyPhoneRegister({
required VerifyPhoneNumberParams params,
});
Future<SuccessModel> verifyOtpCodeRegister({
required VerifyOtpCodeParams params,
});
Future<SuccessModel> register({required RegisterParams params});
}
@LazySingleton(as: AuthDatasource)
class AuthDatasourceImpl implements AuthDatasource {
final RequestHandlerService _requestHandlerService;
AuthDatasourceImpl(this._requestHandlerService);
@override
Future<LoginResponseModel> login({
required String phoneNumber,
required String password,
}) async {
return _requestHandlerService.handleRequest(
path: ApiConst.login,
method: RequestMethodEnum.post,
data: {"password": password, "phoneNumber": phoneNumber},
fromJson: (response) async => LoginResponseModel.fromJson(response.data),
);
}
@override
Future<SuccessModel> register({required RegisterParams params}) async {
return _requestHandlerService.handleRequest(
path: ApiConst.register,
method: RequestMethodEnum.post,
data: {
"firstName": params.firstName,
"lastName": params.lastName,
"password": params.password,
"phoneNumber": params.phoneNumber,
},
fromJson: (response) async {
return SuccessModel.fromJson(response.data);
},
);
}
@override
Future<SuccessModel> resetPassword({
required ResetPasswordParams params,
}) async {
return _requestHandlerService.handleRequest(
path: ApiConst.resetPassword,
method: RequestMethodEnum.post,
data: {
"newPassword": params.newPassword,
"phoneNumber": params.phoneNumber,
},
fromJson: (response) async => SuccessModel.fromJson(response.data),
);
}
@override
Future<SuccessModel> verifyOtpCodeRegister({
required VerifyOtpCodeParams params,
}) async {
return _requestHandlerService.handleRequest(
path: ApiConst.verifyCode,
method: RequestMethodEnum.post,
data: {"code": params.otpCode, "phoneNumber": params.phoneNumber},
fromJson: (response) async => SuccessModel.fromJson(response.data),
);
}
@override
Future<SuccessModel> verifyOtpCodeResetPassword({
required VerifyOtpCodeParams params,
}) async {
return _requestHandlerService.handleRequest(
path: ApiConst.forgotPassword,
method: RequestMethodEnum.post,
data: {"code": params.otpCode, "phoneNumber": params.phoneNumber},
fromJson: (response) async => SuccessModel.fromJson(response.data),
);
}
@override
Future<SuccessModel> verifyPhoneRegister({
required VerifyPhoneNumberParams params,
}) async {
return _requestHandlerService.handleRequest(
path: ApiConst.verifyPhone,
method: RequestMethodEnum.post,
data: {"phoneNumber": params.phoneNumber},
fromJson: (response) async => SuccessModel.fromJson(response.data),
);
}
@override
Future<SuccessModel> verifyPhoneResetPassword({
required VerifyPhoneNumberParams params,
}) async {
return _requestHandlerService.handleRequest(
path: ApiConst.sendCode,
method: RequestMethodEnum.post,
data: {"phoneNumber": params.phoneNumber},
fromJson: (response) async => SuccessModel.fromJson(response.data),
);
}
}

View File

@@ -0,0 +1,26 @@
import 'package:equatable/equatable.dart';
class LoginResponseModel extends Equatable {
final String token;
const LoginResponseModel({required this.token});
factory LoginResponseModel.fromJson(Map<String, dynamic> json) {
return LoginResponseModel(
token: json['token'] as String,
);
}
Map<String, dynamic> toJson() => {
'token': token,
};
LoginResponseModel copyWith({String? token}) {
return LoginResponseModel(
token: token ?? this.token,
);
}
@override
List<Object?> get props => [token];
}

View File

@@ -0,0 +1,90 @@
import 'package:dartz/dartz.dart';
import 'package:food_delivery_client/core/services/request_handler_service.dart';
import 'package:food_delivery_client/feature/auth/data/datasource/auth_datasource.dart';
import 'package:food_delivery_client/feature/auth/data/models/response/login_response.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
import '../../domain/repository/auth_repository.dart';
import '../../domain/usecases/register_usecase.dart';
import '../../domain/usecases/reset_password_usecase.dart';
import '../../domain/usecases/verify_otp_code_login_usecase.dart';
import '../../domain/usecases/verify_phone_login_usecase.dart';
@LazySingleton(as: AuthRepository)
class AuthRepositoryImpl implements AuthRepository {
final RequestHandlerService _requestHandlerService;
final AuthDatasource _authDatasource;
AuthRepositoryImpl(this._requestHandlerService, this._authDatasource);
@override
Future<Either<Failure, LoginResponseModel>> login({
required String phoneNumber,
required String password,
}) async {
return _requestHandlerService.handleRequestInRepository(
onRequest: () async {
return _authDatasource.login(
phoneNumber: phoneNumber,
password: password,
);
},
);
}
@override
Future<Either<Failure, SuccessModel>> register({
required RegisterParams params,
}) async {
return _requestHandlerService.handleRequestInRepository(
onRequest: () async => _authDatasource.register(params: params),
);
}
@override
Future<Either<Failure, SuccessModel>> resetPassword({
required ResetPasswordParams params,
}) async {
return _requestHandlerService.handleRequestInRepository(
onRequest: () => _authDatasource.resetPassword(params: params),
);
}
@override
Future<Either<Failure, SuccessModel>> verifyOtpCodeRegister({
required VerifyOtpCodeParams params,
}) async {
return _requestHandlerService.handleRequestInRepository(
onRequest: () => _authDatasource.verifyOtpCodeRegister(params: params),
);
}
@override
Future<Either<Failure, SuccessModel>> verifyOtpCodeResetPassword({
required VerifyOtpCodeParams params,
}) async {
return _requestHandlerService.handleRequestInRepository(
onRequest: () =>
_authDatasource.verifyOtpCodeResetPassword(params: params),
);
}
@override
Future<Either<Failure, SuccessModel>> verifyPhoneRegister({
required VerifyPhoneNumberParams params,
}) async {
return _requestHandlerService.handleRequestInRepository(
onRequest: () => _authDatasource.verifyPhoneRegister(params: params),
);
}
@override
Future<Either<Failure, SuccessModel>> verifyPhoneResetPassword({
required VerifyPhoneNumberParams params,
}) async {
return _requestHandlerService.handleRequestInRepository(
onRequest: () => _authDatasource.verifyPhoneResetPassword(params: params),
);
}
}

View File

@@ -0,0 +1,43 @@
import 'package:dartz/dartz.dart';
import 'package:food_delivery_client/core/services/request_handler_service.dart';
import 'package:food_delivery_client/feature/auth/data/datasource/auth_datasource.dart';
import 'package:food_delivery_client/feature/auth/data/models/response/login_response.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
import '../usecases/register_usecase.dart';
import '../usecases/reset_password_usecase.dart';
import '../usecases/verify_otp_code_login_usecase.dart';
import '../usecases/verify_phone_login_usecase.dart';
abstract class AuthRepository {
Future<Either<Failure, LoginResponseModel>> login({
required String phoneNumber,
required String password,
});
Future<Either<Failure, SuccessModel>> verifyPhoneResetPassword({
required VerifyPhoneNumberParams params,
});
Future<Either<Failure, SuccessModel>> verifyOtpCodeResetPassword({
required VerifyOtpCodeParams params,
});
Future<Either<Failure, SuccessModel>> resetPassword({
required ResetPasswordParams params,
});
Future<Either<Failure, SuccessModel>> verifyPhoneRegister({
required VerifyPhoneNumberParams params,
});
Future<Either<Failure, SuccessModel>> verifyOtpCodeRegister({
required VerifyOtpCodeParams params,
});
Future<Either<Failure, SuccessModel>> register({
required RegisterParams params,
});
}

View File

@@ -0,0 +1,26 @@
import 'package:dartz/dartz.dart';
import 'package:food_delivery_client/core/usecase/usecase.dart';
import 'package:food_delivery_client/feature/auth/data/models/response/login_response.dart';
import 'package:food_delivery_client/feature/auth/domain/repository/auth_repository.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
@injectable
class LoginUseCase implements UseCase<LoginResponseModel, LoginParams> {
final AuthRepository _authRepository;
LoginUseCase(this._authRepository);
@override
Future<Either<Failure, LoginResponseModel>> call(LoginParams params) async {
return _authRepository.login(
phoneNumber: params.phoneNumber,
password: params.password,
);
}
}
class LoginParams {
final String phoneNumber;
final String password;
LoginParams({required this.phoneNumber, required this.password});
}

View File

@@ -0,0 +1,32 @@
import 'package:dartz/dartz.dart';
import 'package:food_delivery_client/core/exceptions/failure.dart';
import 'package:food_delivery_client/feature/auth/domain/repository/auth_repository.dart';
import 'package:food_delivery_client/feature/common/common.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
import '../../../../core/usecase/usecase.dart';
@injectable
class RegisterUseCase implements UseCase<SuccessModel, RegisterParams> {
final AuthRepository _authRepository;
RegisterUseCase(this._authRepository);
@override
Future<Either<Failure, SuccessModel>> call(RegisterParams params) async {
return _authRepository.register(params: params);
}
}
class RegisterParams {
final String firstName;
final String lastName;
final String phoneNumber;
final String password;
RegisterParams({
required this.firstName,
required this.lastName,
required this.phoneNumber,
required this.password,
});
}

View File

@@ -0,0 +1,26 @@
import 'package:dartz/dartz.dart';
import 'package:food_delivery_client/core/exceptions/failure.dart';
import 'package:food_delivery_client/feature/auth/domain/repository/auth_repository.dart';
import 'package:food_delivery_client/feature/common/common.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
import '../../../../core/usecase/usecase.dart';
@injectable
class ResetPasswordUseCase
implements UseCase<SuccessModel, ResetPasswordParams> {
final AuthRepository _authRepository;
ResetPasswordUseCase(this._authRepository);
@override
Future<Either<Failure, SuccessModel>> call(ResetPasswordParams params) async {
return _authRepository.resetPassword(params: params);
}
}
class ResetPasswordParams {
final String newPassword;
final String phoneNumber;
ResetPasswordParams({required this.newPassword, required this.phoneNumber});
}

View File

@@ -0,0 +1,33 @@
import 'package:dartz/dartz.dart';
import 'package:food_delivery_client/feature/auth/domain/repository/auth_repository.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
import '../../../../core/usecase/usecase.dart';
@injectable
class VerifyOtpCodeForgotPasswordUseCase
implements UseCase<SuccessModel, VerifyOtpCodeParams> {
final AuthRepository _authRepository;
VerifyOtpCodeForgotPasswordUseCase(this._authRepository);
@override
Future<Either<Failure, SuccessModel>> call(VerifyOtpCodeParams params) async {
return _authRepository.verifyOtpCodeResetPassword(params: params);
}
}
class VerifyOtpCodeParams {
final dynamic otpCode;
final String phoneNumber;
VerifyOtpCodeParams({required this.otpCode, required this.phoneNumber});
}
class OtpCodePageParams {
final String phoneNumber;
final bool isRegister;
OtpCodePageParams({required this.phoneNumber, required this.isRegister});
}

View File

@@ -0,0 +1,19 @@
import 'package:dartz/dartz.dart';
import 'package:food_delivery_client/feature/auth/domain/repository/auth_repository.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_otp_code_login_usecase.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
import '../../../../core/usecase/usecase.dart';
@injectable
class VerifyOtpCodeRegisterUseCase
implements UseCase<SuccessModel, VerifyOtpCodeParams> {
final AuthRepository _authRepository;
VerifyOtpCodeRegisterUseCase(this._authRepository);
@override
Future<Either<Failure, SuccessModel>> call(VerifyOtpCodeParams params) async {
return _authRepository.verifyOtpCodeRegister(params: params);
}
}

View File

@@ -0,0 +1,27 @@
import 'package:dartz/dartz.dart';
import 'package:food_delivery_client/core/exceptions/failure.dart';
import 'package:food_delivery_client/feature/auth/domain/repository/auth_repository.dart';
import 'package:food_delivery_client/feature/common/common.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
import '../../../../core/usecase/usecase.dart';
@injectable
class VerifyPhoneNumberLoginUseCase
implements UseCase<SuccessModel, VerifyPhoneNumberParams> {
final AuthRepository _authRepository;
VerifyPhoneNumberLoginUseCase(this._authRepository);
@override
Future<Either<Failure, SuccessModel>> call(
VerifyPhoneNumberParams params,
) async {
return _authRepository.verifyPhoneResetPassword(params: params);
}
}
class VerifyPhoneNumberParams {
final String phoneNumber;
VerifyPhoneNumberParams({required this.phoneNumber});
}

View File

@@ -0,0 +1,21 @@
import 'package:dartz/dartz.dart';
import 'package:food_delivery_client/feature/auth/domain/repository/auth_repository.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_phone_login_usecase.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
import '../../../../core/usecase/usecase.dart';
@injectable
class VerifyPhoneRegisterUseCase
implements UseCase<SuccessModel, VerifyPhoneNumberParams> {
final AuthRepository _authRepository;
VerifyPhoneRegisterUseCase(this._authRepository);
@override
Future<Either<Failure, SuccessModel>> call(
VerifyPhoneNumberParams params,
) async {
return _authRepository.verifyPhoneRegister(params: params);
}
}

View File

@@ -0,0 +1,41 @@
import 'package:food_delivery_client/feature/auth/domain/usecases/login_usecase.dart';
import 'package:food_delivery_client/feature/common/presentation/widgets/w_toastification.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
part 'login_event.dart';
part 'login_state.dart';
part 'login_bloc.freezed.dart';
@injectable
class LoginBloc extends Bloc<LoginEvent, LoginState> {
final LoginUseCase _loginUseCase;
final StorageService _storageService;
LoginBloc(this._loginUseCase, this._storageService)
: super(const LoginState()) {
on<_Login>(_onLogin);
}
Future<void> _onLogin(_Login event, Emitter<LoginState> emit) async {
emit(state.copyWith(status: RequestStatus.loading));
final response = await _loginUseCase.call(event.params);
response.fold(
(l) {
log("${l.errorMessage}");
showErrorToast(l.errorMessage);
emit(state.copyWith(status: RequestStatus.error));
},
(r) {
showSuccessToast("Login success");
_storageService.setString(key: AppLocaleKeys.token, value: r.token);
final token = _storageService.getString(key: AppLocaleKeys.token);
log('Token:$token');
emit(state.copyWith(status: RequestStatus.loaded));
},
);
}
}

View File

@@ -0,0 +1,535 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'login_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$LoginEvent {
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is LoginEvent);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'LoginEvent()';
}
}
/// @nodoc
class $LoginEventCopyWith<$Res> {
$LoginEventCopyWith(LoginEvent _, $Res Function(LoginEvent) __);
}
/// Adds pattern-matching-related methods to [LoginEvent].
extension LoginEventPatterns on LoginEvent {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( _Checked value)? checked,TResult Function( _Login value)? login,required TResult orElse(),}){
final _that = this;
switch (_that) {
case _Checked() when checked != null:
return checked(_that);case _Login() when login != null:
return login(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( _Checked value) checked,required TResult Function( _Login value) login,}){
final _that = this;
switch (_that) {
case _Checked():
return checked(_that);case _Login():
return login(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( _Checked value)? checked,TResult? Function( _Login value)? login,}){
final _that = this;
switch (_that) {
case _Checked() when checked != null:
return checked(_that);case _Login() when login != null:
return login(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function()? checked,TResult Function( LoginParams params)? login,required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Checked() when checked != null:
return checked();case _Login() when login != null:
return login(_that.params);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function() checked,required TResult Function( LoginParams params) login,}) {final _that = this;
switch (_that) {
case _Checked():
return checked();case _Login():
return login(_that.params);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function()? checked,TResult? Function( LoginParams params)? login,}) {final _that = this;
switch (_that) {
case _Checked() when checked != null:
return checked();case _Login() when login != null:
return login(_that.params);case _:
return null;
}
}
}
/// @nodoc
class _Checked implements LoginEvent {
const _Checked();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Checked);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'LoginEvent.checked()';
}
}
/// @nodoc
class _Login implements LoginEvent {
const _Login(this.params);
final LoginParams params;
/// Create a copy of LoginEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$LoginCopyWith<_Login> get copyWith => __$LoginCopyWithImpl<_Login>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Login&&(identical(other.params, params) || other.params == params));
}
@override
int get hashCode => Object.hash(runtimeType,params);
@override
String toString() {
return 'LoginEvent.login(params: $params)';
}
}
/// @nodoc
abstract mixin class _$LoginCopyWith<$Res> implements $LoginEventCopyWith<$Res> {
factory _$LoginCopyWith(_Login value, $Res Function(_Login) _then) = __$LoginCopyWithImpl;
@useResult
$Res call({
LoginParams params
});
}
/// @nodoc
class __$LoginCopyWithImpl<$Res>
implements _$LoginCopyWith<$Res> {
__$LoginCopyWithImpl(this._self, this._then);
final _Login _self;
final $Res Function(_Login) _then;
/// Create a copy of LoginEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? params = null,}) {
return _then(_Login(
null == params ? _self.params : params // ignore: cast_nullable_to_non_nullable
as LoginParams,
));
}
}
/// @nodoc
mixin _$LoginState {
RequestStatus get status;
/// Create a copy of LoginState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$LoginStateCopyWith<LoginState> get copyWith => _$LoginStateCopyWithImpl<LoginState>(this as LoginState, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is LoginState&&(identical(other.status, status) || other.status == status));
}
@override
int get hashCode => Object.hash(runtimeType,status);
@override
String toString() {
return 'LoginState(status: $status)';
}
}
/// @nodoc
abstract mixin class $LoginStateCopyWith<$Res> {
factory $LoginStateCopyWith(LoginState value, $Res Function(LoginState) _then) = _$LoginStateCopyWithImpl;
@useResult
$Res call({
RequestStatus status
});
}
/// @nodoc
class _$LoginStateCopyWithImpl<$Res>
implements $LoginStateCopyWith<$Res> {
_$LoginStateCopyWithImpl(this._self, this._then);
final LoginState _self;
final $Res Function(LoginState) _then;
/// Create a copy of LoginState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? status = null,}) {
return _then(_self.copyWith(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,
));
}
}
/// Adds pattern-matching-related methods to [LoginState].
extension LoginStatePatterns on LoginState {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _LoginState value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _LoginState() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _LoginState value) $default,){
final _that = this;
switch (_that) {
case _LoginState():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _LoginState value)? $default,){
final _that = this;
switch (_that) {
case _LoginState() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( RequestStatus status)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _LoginState() when $default != null:
return $default(_that.status);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( RequestStatus status) $default,) {final _that = this;
switch (_that) {
case _LoginState():
return $default(_that.status);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( RequestStatus status)? $default,) {final _that = this;
switch (_that) {
case _LoginState() when $default != null:
return $default(_that.status);case _:
return null;
}
}
}
/// @nodoc
class _LoginState implements LoginState {
const _LoginState({this.status = RequestStatus.initial});
@override@JsonKey() final RequestStatus status;
/// Create a copy of LoginState
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$LoginStateCopyWith<_LoginState> get copyWith => __$LoginStateCopyWithImpl<_LoginState>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LoginState&&(identical(other.status, status) || other.status == status));
}
@override
int get hashCode => Object.hash(runtimeType,status);
@override
String toString() {
return 'LoginState(status: $status)';
}
}
/// @nodoc
abstract mixin class _$LoginStateCopyWith<$Res> implements $LoginStateCopyWith<$Res> {
factory _$LoginStateCopyWith(_LoginState value, $Res Function(_LoginState) _then) = __$LoginStateCopyWithImpl;
@override @useResult
$Res call({
RequestStatus status
});
}
/// @nodoc
class __$LoginStateCopyWithImpl<$Res>
implements _$LoginStateCopyWith<$Res> {
__$LoginStateCopyWithImpl(this._self, this._then);
final _LoginState _self;
final $Res Function(_LoginState) _then;
/// Create a copy of LoginState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? status = null,}) {
return _then(_LoginState(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,
));
}
}
// dart format on

View File

@@ -0,0 +1,8 @@
part of 'login_bloc.dart';
@freezed
class LoginEvent with _$LoginEvent {
const factory LoginEvent.checked() = _Checked;
const factory LoginEvent.login(LoginParams params) = _Login;
}

View File

@@ -0,0 +1,8 @@
part of 'login_bloc.dart';
@freezed
abstract class LoginState with _$LoginState {
const factory LoginState({
@Default(RequestStatus.initial) RequestStatus status,
}) = _LoginState;
}

View File

@@ -0,0 +1,35 @@
import 'package:food_delivery_client/feature/auth/domain/usecases/register_usecase.dart';
import 'package:food_delivery_client/feature/common/presentation/widgets/w_toastification.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
part 'register_event.dart';
part 'register_state.dart';
part 'register_bloc.freezed.dart';
@injectable
class RegisterBloc extends Bloc<RegisterEvent, RegisterState> {
final RegisterUseCase _registerUseCase;
RegisterBloc(this._registerUseCase) : super(const RegisterState()) {
on<_Loaded>(_onLoaded);
}
Future<void> _onLoaded(_Loaded event, Emitter<RegisterState> emit) async {
emit(state.copyWith(status: RequestStatus.loading));
final response = await _registerUseCase.call(event.params);
response.fold(
(l) {
showErrorToast(l.errorMessage);
emit(state.copyWith(status: RequestStatus.error));
},
(r) {
showSuccessToast(r.message);
emit(state.copyWith(status: RequestStatus.loaded));
},
);
}
}

View File

@@ -0,0 +1,535 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'register_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$RegisterEvent {
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is RegisterEvent);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'RegisterEvent()';
}
}
/// @nodoc
class $RegisterEventCopyWith<$Res> {
$RegisterEventCopyWith(RegisterEvent _, $Res Function(RegisterEvent) __);
}
/// Adds pattern-matching-related methods to [RegisterEvent].
extension RegisterEventPatterns on RegisterEvent {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( _Started value)? started,TResult Function( _Loaded value)? loaded,required TResult orElse(),}){
final _that = this;
switch (_that) {
case _Started() when started != null:
return started(_that);case _Loaded() when loaded != null:
return loaded(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( _Started value) started,required TResult Function( _Loaded value) loaded,}){
final _that = this;
switch (_that) {
case _Started():
return started(_that);case _Loaded():
return loaded(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( _Started value)? started,TResult? Function( _Loaded value)? loaded,}){
final _that = this;
switch (_that) {
case _Started() when started != null:
return started(_that);case _Loaded() when loaded != null:
return loaded(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function()? started,TResult Function( RegisterParams params)? loaded,required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Started() when started != null:
return started();case _Loaded() when loaded != null:
return loaded(_that.params);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function() started,required TResult Function( RegisterParams params) loaded,}) {final _that = this;
switch (_that) {
case _Started():
return started();case _Loaded():
return loaded(_that.params);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function()? started,TResult? Function( RegisterParams params)? loaded,}) {final _that = this;
switch (_that) {
case _Started() when started != null:
return started();case _Loaded() when loaded != null:
return loaded(_that.params);case _:
return null;
}
}
}
/// @nodoc
class _Started implements RegisterEvent {
const _Started();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Started);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'RegisterEvent.started()';
}
}
/// @nodoc
class _Loaded implements RegisterEvent {
const _Loaded(this.params);
final RegisterParams params;
/// Create a copy of RegisterEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$LoadedCopyWith<_Loaded> get copyWith => __$LoadedCopyWithImpl<_Loaded>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Loaded&&(identical(other.params, params) || other.params == params));
}
@override
int get hashCode => Object.hash(runtimeType,params);
@override
String toString() {
return 'RegisterEvent.loaded(params: $params)';
}
}
/// @nodoc
abstract mixin class _$LoadedCopyWith<$Res> implements $RegisterEventCopyWith<$Res> {
factory _$LoadedCopyWith(_Loaded value, $Res Function(_Loaded) _then) = __$LoadedCopyWithImpl;
@useResult
$Res call({
RegisterParams params
});
}
/// @nodoc
class __$LoadedCopyWithImpl<$Res>
implements _$LoadedCopyWith<$Res> {
__$LoadedCopyWithImpl(this._self, this._then);
final _Loaded _self;
final $Res Function(_Loaded) _then;
/// Create a copy of RegisterEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? params = null,}) {
return _then(_Loaded(
null == params ? _self.params : params // ignore: cast_nullable_to_non_nullable
as RegisterParams,
));
}
}
/// @nodoc
mixin _$RegisterState {
RequestStatus get status;
/// Create a copy of RegisterState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$RegisterStateCopyWith<RegisterState> get copyWith => _$RegisterStateCopyWithImpl<RegisterState>(this as RegisterState, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is RegisterState&&(identical(other.status, status) || other.status == status));
}
@override
int get hashCode => Object.hash(runtimeType,status);
@override
String toString() {
return 'RegisterState(status: $status)';
}
}
/// @nodoc
abstract mixin class $RegisterStateCopyWith<$Res> {
factory $RegisterStateCopyWith(RegisterState value, $Res Function(RegisterState) _then) = _$RegisterStateCopyWithImpl;
@useResult
$Res call({
RequestStatus status
});
}
/// @nodoc
class _$RegisterStateCopyWithImpl<$Res>
implements $RegisterStateCopyWith<$Res> {
_$RegisterStateCopyWithImpl(this._self, this._then);
final RegisterState _self;
final $Res Function(RegisterState) _then;
/// Create a copy of RegisterState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? status = null,}) {
return _then(_self.copyWith(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,
));
}
}
/// Adds pattern-matching-related methods to [RegisterState].
extension RegisterStatePatterns on RegisterState {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _RegisterState value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _RegisterState() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _RegisterState value) $default,){
final _that = this;
switch (_that) {
case _RegisterState():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _RegisterState value)? $default,){
final _that = this;
switch (_that) {
case _RegisterState() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( RequestStatus status)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _RegisterState() when $default != null:
return $default(_that.status);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( RequestStatus status) $default,) {final _that = this;
switch (_that) {
case _RegisterState():
return $default(_that.status);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( RequestStatus status)? $default,) {final _that = this;
switch (_that) {
case _RegisterState() when $default != null:
return $default(_that.status);case _:
return null;
}
}
}
/// @nodoc
class _RegisterState implements RegisterState {
const _RegisterState({this.status = RequestStatus.initial});
@override@JsonKey() final RequestStatus status;
/// Create a copy of RegisterState
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$RegisterStateCopyWith<_RegisterState> get copyWith => __$RegisterStateCopyWithImpl<_RegisterState>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _RegisterState&&(identical(other.status, status) || other.status == status));
}
@override
int get hashCode => Object.hash(runtimeType,status);
@override
String toString() {
return 'RegisterState(status: $status)';
}
}
/// @nodoc
abstract mixin class _$RegisterStateCopyWith<$Res> implements $RegisterStateCopyWith<$Res> {
factory _$RegisterStateCopyWith(_RegisterState value, $Res Function(_RegisterState) _then) = __$RegisterStateCopyWithImpl;
@override @useResult
$Res call({
RequestStatus status
});
}
/// @nodoc
class __$RegisterStateCopyWithImpl<$Res>
implements _$RegisterStateCopyWith<$Res> {
__$RegisterStateCopyWithImpl(this._self, this._then);
final _RegisterState _self;
final $Res Function(_RegisterState) _then;
/// Create a copy of RegisterState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? status = null,}) {
return _then(_RegisterState(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,
));
}
}
// dart format on

View File

@@ -0,0 +1,8 @@
part of 'register_bloc.dart';
@freezed
class RegisterEvent with _$RegisterEvent {
const factory RegisterEvent.started() = _Started;
const factory RegisterEvent.loaded(RegisterParams params) = _Loaded;
}

View File

@@ -0,0 +1,8 @@
part of 'register_bloc.dart';
@freezed
abstract class RegisterState with _$RegisterState {
const factory RegisterState({
@Default(RequestStatus.initial) RequestStatus status,
}) = _RegisterState;
}

View File

@@ -0,0 +1,36 @@
import 'package:food_delivery_client/feature/auth/domain/usecases/reset_password_usecase.dart';
import 'package:food_delivery_client/feature/common/presentation/widgets/w_toastification.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
part 'reset_password_event.dart';
part 'reset_password_state.dart';
part 'reset_password_bloc.freezed.dart';
@injectable
class ResetPasswordBloc extends Bloc<ResetPasswordEvent, ResetPasswordState> {
final ResetPasswordUseCase _passwordUseCase;
ResetPasswordBloc(this._passwordUseCase) : super(const ResetPasswordState()) {
on<_Loaded>(_onLoaded);
}
Future<void> _onLoaded(
_Loaded event,
Emitter<ResetPasswordState> emit,
) async {
emit(state.copyWith(status: RequestStatus.loading));
final response = await _passwordUseCase.call(event.params);
response.fold(
(l) {
showErrorToast(l.errorMessage);
emit(state.copyWith(status: RequestStatus.error));
},
(r) {
showSuccessToast(r.message);
emit(state.copyWith(status: RequestStatus.loaded));
},
);
}
}

View File

@@ -0,0 +1,535 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'reset_password_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$ResetPasswordEvent {
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is ResetPasswordEvent);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'ResetPasswordEvent()';
}
}
/// @nodoc
class $ResetPasswordEventCopyWith<$Res> {
$ResetPasswordEventCopyWith(ResetPasswordEvent _, $Res Function(ResetPasswordEvent) __);
}
/// Adds pattern-matching-related methods to [ResetPasswordEvent].
extension ResetPasswordEventPatterns on ResetPasswordEvent {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( _Started value)? started,TResult Function( _Loaded value)? loaded,required TResult orElse(),}){
final _that = this;
switch (_that) {
case _Started() when started != null:
return started(_that);case _Loaded() when loaded != null:
return loaded(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( _Started value) started,required TResult Function( _Loaded value) loaded,}){
final _that = this;
switch (_that) {
case _Started():
return started(_that);case _Loaded():
return loaded(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( _Started value)? started,TResult? Function( _Loaded value)? loaded,}){
final _that = this;
switch (_that) {
case _Started() when started != null:
return started(_that);case _Loaded() when loaded != null:
return loaded(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function()? started,TResult Function( ResetPasswordParams params)? loaded,required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Started() when started != null:
return started();case _Loaded() when loaded != null:
return loaded(_that.params);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function() started,required TResult Function( ResetPasswordParams params) loaded,}) {final _that = this;
switch (_that) {
case _Started():
return started();case _Loaded():
return loaded(_that.params);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function()? started,TResult? Function( ResetPasswordParams params)? loaded,}) {final _that = this;
switch (_that) {
case _Started() when started != null:
return started();case _Loaded() when loaded != null:
return loaded(_that.params);case _:
return null;
}
}
}
/// @nodoc
class _Started implements ResetPasswordEvent {
const _Started();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Started);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'ResetPasswordEvent.started()';
}
}
/// @nodoc
class _Loaded implements ResetPasswordEvent {
const _Loaded(this.params);
final ResetPasswordParams params;
/// Create a copy of ResetPasswordEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$LoadedCopyWith<_Loaded> get copyWith => __$LoadedCopyWithImpl<_Loaded>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Loaded&&(identical(other.params, params) || other.params == params));
}
@override
int get hashCode => Object.hash(runtimeType,params);
@override
String toString() {
return 'ResetPasswordEvent.loaded(params: $params)';
}
}
/// @nodoc
abstract mixin class _$LoadedCopyWith<$Res> implements $ResetPasswordEventCopyWith<$Res> {
factory _$LoadedCopyWith(_Loaded value, $Res Function(_Loaded) _then) = __$LoadedCopyWithImpl;
@useResult
$Res call({
ResetPasswordParams params
});
}
/// @nodoc
class __$LoadedCopyWithImpl<$Res>
implements _$LoadedCopyWith<$Res> {
__$LoadedCopyWithImpl(this._self, this._then);
final _Loaded _self;
final $Res Function(_Loaded) _then;
/// Create a copy of ResetPasswordEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? params = null,}) {
return _then(_Loaded(
null == params ? _self.params : params // ignore: cast_nullable_to_non_nullable
as ResetPasswordParams,
));
}
}
/// @nodoc
mixin _$ResetPasswordState {
RequestStatus get status;
/// Create a copy of ResetPasswordState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$ResetPasswordStateCopyWith<ResetPasswordState> get copyWith => _$ResetPasswordStateCopyWithImpl<ResetPasswordState>(this as ResetPasswordState, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is ResetPasswordState&&(identical(other.status, status) || other.status == status));
}
@override
int get hashCode => Object.hash(runtimeType,status);
@override
String toString() {
return 'ResetPasswordState(status: $status)';
}
}
/// @nodoc
abstract mixin class $ResetPasswordStateCopyWith<$Res> {
factory $ResetPasswordStateCopyWith(ResetPasswordState value, $Res Function(ResetPasswordState) _then) = _$ResetPasswordStateCopyWithImpl;
@useResult
$Res call({
RequestStatus status
});
}
/// @nodoc
class _$ResetPasswordStateCopyWithImpl<$Res>
implements $ResetPasswordStateCopyWith<$Res> {
_$ResetPasswordStateCopyWithImpl(this._self, this._then);
final ResetPasswordState _self;
final $Res Function(ResetPasswordState) _then;
/// Create a copy of ResetPasswordState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? status = null,}) {
return _then(_self.copyWith(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,
));
}
}
/// Adds pattern-matching-related methods to [ResetPasswordState].
extension ResetPasswordStatePatterns on ResetPasswordState {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _ResetPasswordState value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _ResetPasswordState() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _ResetPasswordState value) $default,){
final _that = this;
switch (_that) {
case _ResetPasswordState():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _ResetPasswordState value)? $default,){
final _that = this;
switch (_that) {
case _ResetPasswordState() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( RequestStatus status)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _ResetPasswordState() when $default != null:
return $default(_that.status);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( RequestStatus status) $default,) {final _that = this;
switch (_that) {
case _ResetPasswordState():
return $default(_that.status);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( RequestStatus status)? $default,) {final _that = this;
switch (_that) {
case _ResetPasswordState() when $default != null:
return $default(_that.status);case _:
return null;
}
}
}
/// @nodoc
class _ResetPasswordState implements ResetPasswordState {
const _ResetPasswordState({this.status = RequestStatus.initial});
@override@JsonKey() final RequestStatus status;
/// Create a copy of ResetPasswordState
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$ResetPasswordStateCopyWith<_ResetPasswordState> get copyWith => __$ResetPasswordStateCopyWithImpl<_ResetPasswordState>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ResetPasswordState&&(identical(other.status, status) || other.status == status));
}
@override
int get hashCode => Object.hash(runtimeType,status);
@override
String toString() {
return 'ResetPasswordState(status: $status)';
}
}
/// @nodoc
abstract mixin class _$ResetPasswordStateCopyWith<$Res> implements $ResetPasswordStateCopyWith<$Res> {
factory _$ResetPasswordStateCopyWith(_ResetPasswordState value, $Res Function(_ResetPasswordState) _then) = __$ResetPasswordStateCopyWithImpl;
@override @useResult
$Res call({
RequestStatus status
});
}
/// @nodoc
class __$ResetPasswordStateCopyWithImpl<$Res>
implements _$ResetPasswordStateCopyWith<$Res> {
__$ResetPasswordStateCopyWithImpl(this._self, this._then);
final _ResetPasswordState _self;
final $Res Function(_ResetPasswordState) _then;
/// Create a copy of ResetPasswordState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? status = null,}) {
return _then(_ResetPasswordState(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,
));
}
}
// dart format on

View File

@@ -0,0 +1,8 @@
part of 'reset_password_bloc.dart';
@freezed
class ResetPasswordEvent with _$ResetPasswordEvent {
const factory ResetPasswordEvent.started() = _Started;
const factory ResetPasswordEvent.loaded(ResetPasswordParams params) = _Loaded;
}

View File

@@ -0,0 +1,8 @@
part of 'reset_password_bloc.dart';
@freezed
abstract class ResetPasswordState with _$ResetPasswordState {
const factory ResetPasswordState({
@Default(RequestStatus.initial) RequestStatus status,
}) = _ResetPasswordState;
}

View File

@@ -0,0 +1,140 @@
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_otp_code_login_usecase.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_otp_code_register_usecase.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_phone_login_usecase.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_phone_register_usecase.dart';
import 'package:food_delivery_client/feature/common/presentation/widgets/w_toastification.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
part 'verify_otp_event.dart';
part 'verify_otp_state.dart';
part 'verify_otp_bloc.freezed.dart';
@injectable
class VerifyOtpBloc extends Bloc<VerifyOtpEvent, VerifyOtpState> {
final VerifyOtpCodeRegisterUseCase _registerUseCase;
final VerifyOtpCodeForgotPasswordUseCase _passwordUseCase;
final VerifyPhoneRegisterUseCase _phoneRegisterUseCase;
final VerifyPhoneNumberLoginUseCase _phoneNumberLoginUseCase;
VerifyOtpBloc(
this._registerUseCase,
this._passwordUseCase,
this._phoneRegisterUseCase,
this._phoneNumberLoginUseCase,
) : super(const VerifyOtpState()) {
Timer? timer1;
on<_CancelTimer>((event, emit) {
timer1?.cancel();
});
on<_Started>((event, emit) {
int seconds = state.time;
emit(state.copyWith(time: seconds));
timer1 = Timer.periodic(TimeDelayConst.duration1, (timer) {
if (seconds == 0) {
timer.cancel();
} else {
seconds--;
add(VerifyOtpEvent.ticked(seconds));
}
});
});
on<_Ticked>(_onTicked);
on<_VerifyOtpReset>(_onVerifyOtpReset);
on<_VerifyOtpRegister>(_onVerifyOtpRegister);
on<_ResendRegister>(_onResendVerifyPhoneRegister);
on<_ResendForgot>(_onResendVerifyPhoneForgot);
}
void _onTicked(_Ticked event, Emitter<VerifyOtpState> emit) {
emit(state.copyWith(time: event.seconds));
}
Future<void> _onVerifyOtpReset(
_VerifyOtpReset event,
Emitter<VerifyOtpState> emit,
) async {
emit(state.copyWith(status: RequestStatus.loading));
final response = await _passwordUseCase.call(event.params);
response.fold(
(l) {
showErrorToast(l.errorMessage);
emit(state.copyWith(status: RequestStatus.error));
},
(r) {
showSuccessToast(r.message);
emit(state.copyWith(status: RequestStatus.loaded));
add(VerifyOtpEvent.cancelTimer());
},
);
}
Future<void> _onVerifyOtpRegister(
_VerifyOtpRegister event,
Emitter<VerifyOtpState> emit,
) async {
emit(state.copyWith(status: RequestStatus.loading));
final response = await _registerUseCase.call(event.params);
response.fold(
(l) {
showErrorToast(l.errorMessage);
emit(state.copyWith(status: RequestStatus.error));
},
(r) {
showSuccessToast(r.message);
emit(state.copyWith(status: RequestStatus.loaded));
add(VerifyOtpEvent.cancelTimer());
},
);
}
Future<void> _onResendVerifyPhoneRegister(
_ResendRegister event,
Emitter<VerifyOtpState> emit,
) async {
emit(state.copyWith(resendStatus: RequestStatus.loading));
final response = await _phoneRegisterUseCase.call(
VerifyPhoneNumberParams(phoneNumber: event.phoneNUmber),
);
response.fold(
(l) {
showErrorToast(l.errorMessage);
emit(state.copyWith(resendStatus: RequestStatus.error));
},
(r) {
emit(state.copyWith(resendStatus: RequestStatus.loaded));
add(VerifyOtpEvent.ticked(120));
add(VerifyOtpEvent.started());
},
);
}
Future<void> _onResendVerifyPhoneForgot(
_ResendForgot event,
Emitter<VerifyOtpState> emit,
) async {
emit(state.copyWith(resendStatus: RequestStatus.loading));
final response = await _phoneNumberLoginUseCase.call(
VerifyPhoneNumberParams(phoneNumber: event.phoneNUmber),
);
response.fold(
(l) {
showErrorToast(l.errorMessage);
emit(state.copyWith(resendStatus: RequestStatus.error));
},
(r) {
emit(state.copyWith(resendStatus: RequestStatus.loaded));
add(VerifyOtpEvent.ticked(120));
add(VerifyOtpEvent.started());
},
);
}
}

View File

@@ -0,0 +1,867 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'verify_otp_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$VerifyOtpEvent {
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is VerifyOtpEvent);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'VerifyOtpEvent()';
}
}
/// @nodoc
class $VerifyOtpEventCopyWith<$Res> {
$VerifyOtpEventCopyWith(VerifyOtpEvent _, $Res Function(VerifyOtpEvent) __);
}
/// Adds pattern-matching-related methods to [VerifyOtpEvent].
extension VerifyOtpEventPatterns on VerifyOtpEvent {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( _Started value)? started,TResult Function( _CancelTimer value)? cancelTimer,TResult Function( _ResendRegister value)? resendRegister,TResult Function( _ResendForgot value)? resendForgot,TResult Function( _Ticked value)? ticked,TResult Function( _VerifyOtpReset value)? verifyOtpReset,TResult Function( _VerifyOtpRegister value)? verifyOtpRegister,required TResult orElse(),}){
final _that = this;
switch (_that) {
case _Started() when started != null:
return started(_that);case _CancelTimer() when cancelTimer != null:
return cancelTimer(_that);case _ResendRegister() when resendRegister != null:
return resendRegister(_that);case _ResendForgot() when resendForgot != null:
return resendForgot(_that);case _Ticked() when ticked != null:
return ticked(_that);case _VerifyOtpReset() when verifyOtpReset != null:
return verifyOtpReset(_that);case _VerifyOtpRegister() when verifyOtpRegister != null:
return verifyOtpRegister(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( _Started value) started,required TResult Function( _CancelTimer value) cancelTimer,required TResult Function( _ResendRegister value) resendRegister,required TResult Function( _ResendForgot value) resendForgot,required TResult Function( _Ticked value) ticked,required TResult Function( _VerifyOtpReset value) verifyOtpReset,required TResult Function( _VerifyOtpRegister value) verifyOtpRegister,}){
final _that = this;
switch (_that) {
case _Started():
return started(_that);case _CancelTimer():
return cancelTimer(_that);case _ResendRegister():
return resendRegister(_that);case _ResendForgot():
return resendForgot(_that);case _Ticked():
return ticked(_that);case _VerifyOtpReset():
return verifyOtpReset(_that);case _VerifyOtpRegister():
return verifyOtpRegister(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( _Started value)? started,TResult? Function( _CancelTimer value)? cancelTimer,TResult? Function( _ResendRegister value)? resendRegister,TResult? Function( _ResendForgot value)? resendForgot,TResult? Function( _Ticked value)? ticked,TResult? Function( _VerifyOtpReset value)? verifyOtpReset,TResult? Function( _VerifyOtpRegister value)? verifyOtpRegister,}){
final _that = this;
switch (_that) {
case _Started() when started != null:
return started(_that);case _CancelTimer() when cancelTimer != null:
return cancelTimer(_that);case _ResendRegister() when resendRegister != null:
return resendRegister(_that);case _ResendForgot() when resendForgot != null:
return resendForgot(_that);case _Ticked() when ticked != null:
return ticked(_that);case _VerifyOtpReset() when verifyOtpReset != null:
return verifyOtpReset(_that);case _VerifyOtpRegister() when verifyOtpRegister != null:
return verifyOtpRegister(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function()? started,TResult Function()? cancelTimer,TResult Function( String phoneNUmber)? resendRegister,TResult Function( String phoneNUmber)? resendForgot,TResult Function( int seconds)? ticked,TResult Function( VerifyOtpCodeParams params)? verifyOtpReset,TResult Function( VerifyOtpCodeParams params)? verifyOtpRegister,required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Started() when started != null:
return started();case _CancelTimer() when cancelTimer != null:
return cancelTimer();case _ResendRegister() when resendRegister != null:
return resendRegister(_that.phoneNUmber);case _ResendForgot() when resendForgot != null:
return resendForgot(_that.phoneNUmber);case _Ticked() when ticked != null:
return ticked(_that.seconds);case _VerifyOtpReset() when verifyOtpReset != null:
return verifyOtpReset(_that.params);case _VerifyOtpRegister() when verifyOtpRegister != null:
return verifyOtpRegister(_that.params);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function() started,required TResult Function() cancelTimer,required TResult Function( String phoneNUmber) resendRegister,required TResult Function( String phoneNUmber) resendForgot,required TResult Function( int seconds) ticked,required TResult Function( VerifyOtpCodeParams params) verifyOtpReset,required TResult Function( VerifyOtpCodeParams params) verifyOtpRegister,}) {final _that = this;
switch (_that) {
case _Started():
return started();case _CancelTimer():
return cancelTimer();case _ResendRegister():
return resendRegister(_that.phoneNUmber);case _ResendForgot():
return resendForgot(_that.phoneNUmber);case _Ticked():
return ticked(_that.seconds);case _VerifyOtpReset():
return verifyOtpReset(_that.params);case _VerifyOtpRegister():
return verifyOtpRegister(_that.params);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function()? started,TResult? Function()? cancelTimer,TResult? Function( String phoneNUmber)? resendRegister,TResult? Function( String phoneNUmber)? resendForgot,TResult? Function( int seconds)? ticked,TResult? Function( VerifyOtpCodeParams params)? verifyOtpReset,TResult? Function( VerifyOtpCodeParams params)? verifyOtpRegister,}) {final _that = this;
switch (_that) {
case _Started() when started != null:
return started();case _CancelTimer() when cancelTimer != null:
return cancelTimer();case _ResendRegister() when resendRegister != null:
return resendRegister(_that.phoneNUmber);case _ResendForgot() when resendForgot != null:
return resendForgot(_that.phoneNUmber);case _Ticked() when ticked != null:
return ticked(_that.seconds);case _VerifyOtpReset() when verifyOtpReset != null:
return verifyOtpReset(_that.params);case _VerifyOtpRegister() when verifyOtpRegister != null:
return verifyOtpRegister(_that.params);case _:
return null;
}
}
}
/// @nodoc
class _Started implements VerifyOtpEvent {
const _Started();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Started);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'VerifyOtpEvent.started()';
}
}
/// @nodoc
class _CancelTimer implements VerifyOtpEvent {
const _CancelTimer();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _CancelTimer);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'VerifyOtpEvent.cancelTimer()';
}
}
/// @nodoc
class _ResendRegister implements VerifyOtpEvent {
const _ResendRegister(this.phoneNUmber);
final String phoneNUmber;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$ResendRegisterCopyWith<_ResendRegister> get copyWith => __$ResendRegisterCopyWithImpl<_ResendRegister>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ResendRegister&&(identical(other.phoneNUmber, phoneNUmber) || other.phoneNUmber == phoneNUmber));
}
@override
int get hashCode => Object.hash(runtimeType,phoneNUmber);
@override
String toString() {
return 'VerifyOtpEvent.resendRegister(phoneNUmber: $phoneNUmber)';
}
}
/// @nodoc
abstract mixin class _$ResendRegisterCopyWith<$Res> implements $VerifyOtpEventCopyWith<$Res> {
factory _$ResendRegisterCopyWith(_ResendRegister value, $Res Function(_ResendRegister) _then) = __$ResendRegisterCopyWithImpl;
@useResult
$Res call({
String phoneNUmber
});
}
/// @nodoc
class __$ResendRegisterCopyWithImpl<$Res>
implements _$ResendRegisterCopyWith<$Res> {
__$ResendRegisterCopyWithImpl(this._self, this._then);
final _ResendRegister _self;
final $Res Function(_ResendRegister) _then;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? phoneNUmber = null,}) {
return _then(_ResendRegister(
null == phoneNUmber ? _self.phoneNUmber : phoneNUmber // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
class _ResendForgot implements VerifyOtpEvent {
const _ResendForgot(this.phoneNUmber);
final String phoneNUmber;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$ResendForgotCopyWith<_ResendForgot> get copyWith => __$ResendForgotCopyWithImpl<_ResendForgot>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ResendForgot&&(identical(other.phoneNUmber, phoneNUmber) || other.phoneNUmber == phoneNUmber));
}
@override
int get hashCode => Object.hash(runtimeType,phoneNUmber);
@override
String toString() {
return 'VerifyOtpEvent.resendForgot(phoneNUmber: $phoneNUmber)';
}
}
/// @nodoc
abstract mixin class _$ResendForgotCopyWith<$Res> implements $VerifyOtpEventCopyWith<$Res> {
factory _$ResendForgotCopyWith(_ResendForgot value, $Res Function(_ResendForgot) _then) = __$ResendForgotCopyWithImpl;
@useResult
$Res call({
String phoneNUmber
});
}
/// @nodoc
class __$ResendForgotCopyWithImpl<$Res>
implements _$ResendForgotCopyWith<$Res> {
__$ResendForgotCopyWithImpl(this._self, this._then);
final _ResendForgot _self;
final $Res Function(_ResendForgot) _then;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? phoneNUmber = null,}) {
return _then(_ResendForgot(
null == phoneNUmber ? _self.phoneNUmber : phoneNUmber // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
class _Ticked implements VerifyOtpEvent {
const _Ticked(this.seconds);
final int seconds;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$TickedCopyWith<_Ticked> get copyWith => __$TickedCopyWithImpl<_Ticked>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Ticked&&(identical(other.seconds, seconds) || other.seconds == seconds));
}
@override
int get hashCode => Object.hash(runtimeType,seconds);
@override
String toString() {
return 'VerifyOtpEvent.ticked(seconds: $seconds)';
}
}
/// @nodoc
abstract mixin class _$TickedCopyWith<$Res> implements $VerifyOtpEventCopyWith<$Res> {
factory _$TickedCopyWith(_Ticked value, $Res Function(_Ticked) _then) = __$TickedCopyWithImpl;
@useResult
$Res call({
int seconds
});
}
/// @nodoc
class __$TickedCopyWithImpl<$Res>
implements _$TickedCopyWith<$Res> {
__$TickedCopyWithImpl(this._self, this._then);
final _Ticked _self;
final $Res Function(_Ticked) _then;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? seconds = null,}) {
return _then(_Ticked(
null == seconds ? _self.seconds : seconds // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
class _VerifyOtpReset implements VerifyOtpEvent {
const _VerifyOtpReset(this.params);
final VerifyOtpCodeParams params;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$VerifyOtpResetCopyWith<_VerifyOtpReset> get copyWith => __$VerifyOtpResetCopyWithImpl<_VerifyOtpReset>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _VerifyOtpReset&&(identical(other.params, params) || other.params == params));
}
@override
int get hashCode => Object.hash(runtimeType,params);
@override
String toString() {
return 'VerifyOtpEvent.verifyOtpReset(params: $params)';
}
}
/// @nodoc
abstract mixin class _$VerifyOtpResetCopyWith<$Res> implements $VerifyOtpEventCopyWith<$Res> {
factory _$VerifyOtpResetCopyWith(_VerifyOtpReset value, $Res Function(_VerifyOtpReset) _then) = __$VerifyOtpResetCopyWithImpl;
@useResult
$Res call({
VerifyOtpCodeParams params
});
}
/// @nodoc
class __$VerifyOtpResetCopyWithImpl<$Res>
implements _$VerifyOtpResetCopyWith<$Res> {
__$VerifyOtpResetCopyWithImpl(this._self, this._then);
final _VerifyOtpReset _self;
final $Res Function(_VerifyOtpReset) _then;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? params = null,}) {
return _then(_VerifyOtpReset(
null == params ? _self.params : params // ignore: cast_nullable_to_non_nullable
as VerifyOtpCodeParams,
));
}
}
/// @nodoc
class _VerifyOtpRegister implements VerifyOtpEvent {
const _VerifyOtpRegister(this.params);
final VerifyOtpCodeParams params;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$VerifyOtpRegisterCopyWith<_VerifyOtpRegister> get copyWith => __$VerifyOtpRegisterCopyWithImpl<_VerifyOtpRegister>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _VerifyOtpRegister&&(identical(other.params, params) || other.params == params));
}
@override
int get hashCode => Object.hash(runtimeType,params);
@override
String toString() {
return 'VerifyOtpEvent.verifyOtpRegister(params: $params)';
}
}
/// @nodoc
abstract mixin class _$VerifyOtpRegisterCopyWith<$Res> implements $VerifyOtpEventCopyWith<$Res> {
factory _$VerifyOtpRegisterCopyWith(_VerifyOtpRegister value, $Res Function(_VerifyOtpRegister) _then) = __$VerifyOtpRegisterCopyWithImpl;
@useResult
$Res call({
VerifyOtpCodeParams params
});
}
/// @nodoc
class __$VerifyOtpRegisterCopyWithImpl<$Res>
implements _$VerifyOtpRegisterCopyWith<$Res> {
__$VerifyOtpRegisterCopyWithImpl(this._self, this._then);
final _VerifyOtpRegister _self;
final $Res Function(_VerifyOtpRegister) _then;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? params = null,}) {
return _then(_VerifyOtpRegister(
null == params ? _self.params : params // ignore: cast_nullable_to_non_nullable
as VerifyOtpCodeParams,
));
}
}
/// @nodoc
mixin _$VerifyOtpState {
RequestStatus get status; RequestStatus get resendStatus; int get time;
/// Create a copy of VerifyOtpState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$VerifyOtpStateCopyWith<VerifyOtpState> get copyWith => _$VerifyOtpStateCopyWithImpl<VerifyOtpState>(this as VerifyOtpState, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is VerifyOtpState&&(identical(other.status, status) || other.status == status)&&(identical(other.resendStatus, resendStatus) || other.resendStatus == resendStatus)&&(identical(other.time, time) || other.time == time));
}
@override
int get hashCode => Object.hash(runtimeType,status,resendStatus,time);
@override
String toString() {
return 'VerifyOtpState(status: $status, resendStatus: $resendStatus, time: $time)';
}
}
/// @nodoc
abstract mixin class $VerifyOtpStateCopyWith<$Res> {
factory $VerifyOtpStateCopyWith(VerifyOtpState value, $Res Function(VerifyOtpState) _then) = _$VerifyOtpStateCopyWithImpl;
@useResult
$Res call({
RequestStatus status, RequestStatus resendStatus, int time
});
}
/// @nodoc
class _$VerifyOtpStateCopyWithImpl<$Res>
implements $VerifyOtpStateCopyWith<$Res> {
_$VerifyOtpStateCopyWithImpl(this._self, this._then);
final VerifyOtpState _self;
final $Res Function(VerifyOtpState) _then;
/// Create a copy of VerifyOtpState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? status = null,Object? resendStatus = null,Object? time = null,}) {
return _then(_self.copyWith(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,resendStatus: null == resendStatus ? _self.resendStatus : resendStatus // ignore: cast_nullable_to_non_nullable
as RequestStatus,time: null == time ? _self.time : time // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// Adds pattern-matching-related methods to [VerifyOtpState].
extension VerifyOtpStatePatterns on VerifyOtpState {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _VerifyOtpState value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _VerifyOtpState() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _VerifyOtpState value) $default,){
final _that = this;
switch (_that) {
case _VerifyOtpState():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _VerifyOtpState value)? $default,){
final _that = this;
switch (_that) {
case _VerifyOtpState() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( RequestStatus status, RequestStatus resendStatus, int time)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _VerifyOtpState() when $default != null:
return $default(_that.status,_that.resendStatus,_that.time);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( RequestStatus status, RequestStatus resendStatus, int time) $default,) {final _that = this;
switch (_that) {
case _VerifyOtpState():
return $default(_that.status,_that.resendStatus,_that.time);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( RequestStatus status, RequestStatus resendStatus, int time)? $default,) {final _that = this;
switch (_that) {
case _VerifyOtpState() when $default != null:
return $default(_that.status,_that.resendStatus,_that.time);case _:
return null;
}
}
}
/// @nodoc
class _VerifyOtpState implements VerifyOtpState {
const _VerifyOtpState({this.status = RequestStatus.initial, this.resendStatus = RequestStatus.initial, this.time = 120});
@override@JsonKey() final RequestStatus status;
@override@JsonKey() final RequestStatus resendStatus;
@override@JsonKey() final int time;
/// Create a copy of VerifyOtpState
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$VerifyOtpStateCopyWith<_VerifyOtpState> get copyWith => __$VerifyOtpStateCopyWithImpl<_VerifyOtpState>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _VerifyOtpState&&(identical(other.status, status) || other.status == status)&&(identical(other.resendStatus, resendStatus) || other.resendStatus == resendStatus)&&(identical(other.time, time) || other.time == time));
}
@override
int get hashCode => Object.hash(runtimeType,status,resendStatus,time);
@override
String toString() {
return 'VerifyOtpState(status: $status, resendStatus: $resendStatus, time: $time)';
}
}
/// @nodoc
abstract mixin class _$VerifyOtpStateCopyWith<$Res> implements $VerifyOtpStateCopyWith<$Res> {
factory _$VerifyOtpStateCopyWith(_VerifyOtpState value, $Res Function(_VerifyOtpState) _then) = __$VerifyOtpStateCopyWithImpl;
@override @useResult
$Res call({
RequestStatus status, RequestStatus resendStatus, int time
});
}
/// @nodoc
class __$VerifyOtpStateCopyWithImpl<$Res>
implements _$VerifyOtpStateCopyWith<$Res> {
__$VerifyOtpStateCopyWithImpl(this._self, this._then);
final _VerifyOtpState _self;
final $Res Function(_VerifyOtpState) _then;
/// Create a copy of VerifyOtpState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? status = null,Object? resendStatus = null,Object? time = null,}) {
return _then(_VerifyOtpState(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,resendStatus: null == resendStatus ? _self.resendStatus : resendStatus // ignore: cast_nullable_to_non_nullable
as RequestStatus,time: null == time ? _self.time : time // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
// dart format on

View File

@@ -0,0 +1,19 @@
part of 'verify_otp_bloc.dart';
@freezed
class VerifyOtpEvent with _$VerifyOtpEvent {
const factory VerifyOtpEvent.started() = _Started;
const factory VerifyOtpEvent.cancelTimer() = _CancelTimer;
const factory VerifyOtpEvent.resendRegister(String phoneNUmber) =
_ResendRegister;
const factory VerifyOtpEvent.resendForgot(String phoneNUmber) = _ResendForgot;
const factory VerifyOtpEvent.ticked(int seconds) = _Ticked;
const factory VerifyOtpEvent.verifyOtpReset(VerifyOtpCodeParams params) =
_VerifyOtpReset;
const factory VerifyOtpEvent.verifyOtpRegister(VerifyOtpCodeParams params) =
_VerifyOtpRegister;
}

View File

@@ -0,0 +1,10 @@
part of 'verify_otp_bloc.dart';
@freezed
abstract class VerifyOtpState with _$VerifyOtpState {
const factory VerifyOtpState({
@Default(RequestStatus.initial) RequestStatus status,
@Default(RequestStatus.initial) RequestStatus resendStatus,
@Default(120) int time,
}) = _VerifyOtpState;
}

View File

@@ -0,0 +1,60 @@
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_phone_login_usecase.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_phone_register_usecase.dart';
import 'package:food_delivery_client/feature/common/presentation/widgets/w_toastification.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
part 'verify_phone_event.dart';
part 'verify_phone_state.dart';
part 'verify_phone_bloc.freezed.dart';
@injectable
class VerifyPhoneBloc extends Bloc<VerifyPhoneEvent, VerifyPhoneState> {
final VerifyPhoneNumberLoginUseCase _loginUseCase;
final VerifyPhoneRegisterUseCase _registerUseCase;
VerifyPhoneBloc(this._loginUseCase, this._registerUseCase)
: super(const VerifyPhoneState()) {
on<_VerifyPhoneRegister>(_onVerifyPhoneNumberRegister);
on<_VerifyPhoneReset>(_onVerifyPhoneReset);
}
Future<void> _onVerifyPhoneNumberRegister(
_VerifyPhoneRegister event,
Emitter<VerifyPhoneState> emit,
) async {
emit(state.copyWith(status: RequestStatus.loading));
final response = await _registerUseCase.call(event.params);
response.fold(
(l) {
showErrorToast(l.errorMessage);
emit(state.copyWith(status: RequestStatus.error));
},
(r) {
showSuccessToast(r.message);
emit(state.copyWith(status: RequestStatus.loaded));
},
);
}
Future<void> _onVerifyPhoneReset(
_VerifyPhoneReset event,
Emitter<VerifyPhoneState> emit,
) async {
emit(state.copyWith(status: RequestStatus.loading));
final response = await _loginUseCase.call(event.params);
response.fold(
(l) {
showErrorToast(l.errorMessage);
emit(state.copyWith(status: RequestStatus.error));
},
(r) {
showSuccessToast(r.message);
emit(state.copyWith(status: RequestStatus.loaded));
},
);
}
}

View File

@@ -0,0 +1,607 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'verify_phone_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$VerifyPhoneEvent {
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is VerifyPhoneEvent);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'VerifyPhoneEvent()';
}
}
/// @nodoc
class $VerifyPhoneEventCopyWith<$Res> {
$VerifyPhoneEventCopyWith(VerifyPhoneEvent _, $Res Function(VerifyPhoneEvent) __);
}
/// Adds pattern-matching-related methods to [VerifyPhoneEvent].
extension VerifyPhoneEventPatterns on VerifyPhoneEvent {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( _Started value)? started,TResult Function( _VerifyPhoneRegister value)? verifyPhoneRegister,TResult Function( _VerifyPhoneReset value)? verifyPhoneReset,required TResult orElse(),}){
final _that = this;
switch (_that) {
case _Started() when started != null:
return started(_that);case _VerifyPhoneRegister() when verifyPhoneRegister != null:
return verifyPhoneRegister(_that);case _VerifyPhoneReset() when verifyPhoneReset != null:
return verifyPhoneReset(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( _Started value) started,required TResult Function( _VerifyPhoneRegister value) verifyPhoneRegister,required TResult Function( _VerifyPhoneReset value) verifyPhoneReset,}){
final _that = this;
switch (_that) {
case _Started():
return started(_that);case _VerifyPhoneRegister():
return verifyPhoneRegister(_that);case _VerifyPhoneReset():
return verifyPhoneReset(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( _Started value)? started,TResult? Function( _VerifyPhoneRegister value)? verifyPhoneRegister,TResult? Function( _VerifyPhoneReset value)? verifyPhoneReset,}){
final _that = this;
switch (_that) {
case _Started() when started != null:
return started(_that);case _VerifyPhoneRegister() when verifyPhoneRegister != null:
return verifyPhoneRegister(_that);case _VerifyPhoneReset() when verifyPhoneReset != null:
return verifyPhoneReset(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function()? started,TResult Function( VerifyPhoneNumberParams params)? verifyPhoneRegister,TResult Function( VerifyPhoneNumberParams params)? verifyPhoneReset,required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Started() when started != null:
return started();case _VerifyPhoneRegister() when verifyPhoneRegister != null:
return verifyPhoneRegister(_that.params);case _VerifyPhoneReset() when verifyPhoneReset != null:
return verifyPhoneReset(_that.params);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function() started,required TResult Function( VerifyPhoneNumberParams params) verifyPhoneRegister,required TResult Function( VerifyPhoneNumberParams params) verifyPhoneReset,}) {final _that = this;
switch (_that) {
case _Started():
return started();case _VerifyPhoneRegister():
return verifyPhoneRegister(_that.params);case _VerifyPhoneReset():
return verifyPhoneReset(_that.params);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function()? started,TResult? Function( VerifyPhoneNumberParams params)? verifyPhoneRegister,TResult? Function( VerifyPhoneNumberParams params)? verifyPhoneReset,}) {final _that = this;
switch (_that) {
case _Started() when started != null:
return started();case _VerifyPhoneRegister() when verifyPhoneRegister != null:
return verifyPhoneRegister(_that.params);case _VerifyPhoneReset() when verifyPhoneReset != null:
return verifyPhoneReset(_that.params);case _:
return null;
}
}
}
/// @nodoc
class _Started implements VerifyPhoneEvent {
const _Started();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Started);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'VerifyPhoneEvent.started()';
}
}
/// @nodoc
class _VerifyPhoneRegister implements VerifyPhoneEvent {
const _VerifyPhoneRegister(this.params);
final VerifyPhoneNumberParams params;
/// Create a copy of VerifyPhoneEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$VerifyPhoneRegisterCopyWith<_VerifyPhoneRegister> get copyWith => __$VerifyPhoneRegisterCopyWithImpl<_VerifyPhoneRegister>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _VerifyPhoneRegister&&(identical(other.params, params) || other.params == params));
}
@override
int get hashCode => Object.hash(runtimeType,params);
@override
String toString() {
return 'VerifyPhoneEvent.verifyPhoneRegister(params: $params)';
}
}
/// @nodoc
abstract mixin class _$VerifyPhoneRegisterCopyWith<$Res> implements $VerifyPhoneEventCopyWith<$Res> {
factory _$VerifyPhoneRegisterCopyWith(_VerifyPhoneRegister value, $Res Function(_VerifyPhoneRegister) _then) = __$VerifyPhoneRegisterCopyWithImpl;
@useResult
$Res call({
VerifyPhoneNumberParams params
});
}
/// @nodoc
class __$VerifyPhoneRegisterCopyWithImpl<$Res>
implements _$VerifyPhoneRegisterCopyWith<$Res> {
__$VerifyPhoneRegisterCopyWithImpl(this._self, this._then);
final _VerifyPhoneRegister _self;
final $Res Function(_VerifyPhoneRegister) _then;
/// Create a copy of VerifyPhoneEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? params = null,}) {
return _then(_VerifyPhoneRegister(
null == params ? _self.params : params // ignore: cast_nullable_to_non_nullable
as VerifyPhoneNumberParams,
));
}
}
/// @nodoc
class _VerifyPhoneReset implements VerifyPhoneEvent {
const _VerifyPhoneReset(this.params);
final VerifyPhoneNumberParams params;
/// Create a copy of VerifyPhoneEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$VerifyPhoneResetCopyWith<_VerifyPhoneReset> get copyWith => __$VerifyPhoneResetCopyWithImpl<_VerifyPhoneReset>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _VerifyPhoneReset&&(identical(other.params, params) || other.params == params));
}
@override
int get hashCode => Object.hash(runtimeType,params);
@override
String toString() {
return 'VerifyPhoneEvent.verifyPhoneReset(params: $params)';
}
}
/// @nodoc
abstract mixin class _$VerifyPhoneResetCopyWith<$Res> implements $VerifyPhoneEventCopyWith<$Res> {
factory _$VerifyPhoneResetCopyWith(_VerifyPhoneReset value, $Res Function(_VerifyPhoneReset) _then) = __$VerifyPhoneResetCopyWithImpl;
@useResult
$Res call({
VerifyPhoneNumberParams params
});
}
/// @nodoc
class __$VerifyPhoneResetCopyWithImpl<$Res>
implements _$VerifyPhoneResetCopyWith<$Res> {
__$VerifyPhoneResetCopyWithImpl(this._self, this._then);
final _VerifyPhoneReset _self;
final $Res Function(_VerifyPhoneReset) _then;
/// Create a copy of VerifyPhoneEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? params = null,}) {
return _then(_VerifyPhoneReset(
null == params ? _self.params : params // ignore: cast_nullable_to_non_nullable
as VerifyPhoneNumberParams,
));
}
}
/// @nodoc
mixin _$VerifyPhoneState {
RequestStatus get status;
/// Create a copy of VerifyPhoneState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$VerifyPhoneStateCopyWith<VerifyPhoneState> get copyWith => _$VerifyPhoneStateCopyWithImpl<VerifyPhoneState>(this as VerifyPhoneState, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is VerifyPhoneState&&(identical(other.status, status) || other.status == status));
}
@override
int get hashCode => Object.hash(runtimeType,status);
@override
String toString() {
return 'VerifyPhoneState(status: $status)';
}
}
/// @nodoc
abstract mixin class $VerifyPhoneStateCopyWith<$Res> {
factory $VerifyPhoneStateCopyWith(VerifyPhoneState value, $Res Function(VerifyPhoneState) _then) = _$VerifyPhoneStateCopyWithImpl;
@useResult
$Res call({
RequestStatus status
});
}
/// @nodoc
class _$VerifyPhoneStateCopyWithImpl<$Res>
implements $VerifyPhoneStateCopyWith<$Res> {
_$VerifyPhoneStateCopyWithImpl(this._self, this._then);
final VerifyPhoneState _self;
final $Res Function(VerifyPhoneState) _then;
/// Create a copy of VerifyPhoneState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? status = null,}) {
return _then(_self.copyWith(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,
));
}
}
/// Adds pattern-matching-related methods to [VerifyPhoneState].
extension VerifyPhoneStatePatterns on VerifyPhoneState {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _VerifyPhoneState value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _VerifyPhoneState() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _VerifyPhoneState value) $default,){
final _that = this;
switch (_that) {
case _VerifyPhoneState():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _VerifyPhoneState value)? $default,){
final _that = this;
switch (_that) {
case _VerifyPhoneState() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( RequestStatus status)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _VerifyPhoneState() when $default != null:
return $default(_that.status);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( RequestStatus status) $default,) {final _that = this;
switch (_that) {
case _VerifyPhoneState():
return $default(_that.status);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( RequestStatus status)? $default,) {final _that = this;
switch (_that) {
case _VerifyPhoneState() when $default != null:
return $default(_that.status);case _:
return null;
}
}
}
/// @nodoc
class _VerifyPhoneState implements VerifyPhoneState {
const _VerifyPhoneState({this.status = RequestStatus.initial});
@override@JsonKey() final RequestStatus status;
/// Create a copy of VerifyPhoneState
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$VerifyPhoneStateCopyWith<_VerifyPhoneState> get copyWith => __$VerifyPhoneStateCopyWithImpl<_VerifyPhoneState>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _VerifyPhoneState&&(identical(other.status, status) || other.status == status));
}
@override
int get hashCode => Object.hash(runtimeType,status);
@override
String toString() {
return 'VerifyPhoneState(status: $status)';
}
}
/// @nodoc
abstract mixin class _$VerifyPhoneStateCopyWith<$Res> implements $VerifyPhoneStateCopyWith<$Res> {
factory _$VerifyPhoneStateCopyWith(_VerifyPhoneState value, $Res Function(_VerifyPhoneState) _then) = __$VerifyPhoneStateCopyWithImpl;
@override @useResult
$Res call({
RequestStatus status
});
}
/// @nodoc
class __$VerifyPhoneStateCopyWithImpl<$Res>
implements _$VerifyPhoneStateCopyWith<$Res> {
__$VerifyPhoneStateCopyWithImpl(this._self, this._then);
final _VerifyPhoneState _self;
final $Res Function(_VerifyPhoneState) _then;
/// Create a copy of VerifyPhoneState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? status = null,}) {
return _then(_VerifyPhoneState(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,
));
}
}
// dart format on

View File

@@ -0,0 +1,14 @@
part of 'verify_phone_bloc.dart';
@freezed
class VerifyPhoneEvent with _$VerifyPhoneEvent {
const factory VerifyPhoneEvent.started() = _Started;
const factory VerifyPhoneEvent.verifyPhoneRegister(
VerifyPhoneNumberParams params,
) = _VerifyPhoneRegister;
const factory VerifyPhoneEvent.verifyPhoneReset(
VerifyPhoneNumberParams params,
) = _VerifyPhoneReset;
}

View File

@@ -0,0 +1,8 @@
part of 'verify_phone_bloc.dart';
@freezed
abstract class VerifyPhoneState with _$VerifyPhoneState {
const factory VerifyPhoneState({
@Default(RequestStatus.initial) RequestStatus status,
}) = _VerifyPhoneState;
}

View File

@@ -1,15 +0,0 @@
import 'package:food_delivery_client/feature/auth/presentation/login_page/widgets/login_body.dart';
import 'package:food_delivery_client/feature/common/presentation/widgets/w_back_button.dart';
import '../../../../food_delivery_client.dart';
class LoginPage extends StatelessWidget {
const LoginPage({super.key});
@override
Widget build(BuildContext context) {
return WLoginBody();
}
}

View File

@@ -1,203 +0,0 @@
import 'package:food_delivery_client/core/helpers/formatters.dart';
import 'package:food_delivery_client/core/helpers/validator_helpers.dart';
import 'package:food_delivery_client/feature/auth/presentation/login_page/widgets/welcome_text.dart';
import 'package:food_delivery_client/feature/common/presentation/widgets/app_text_form_field.dart';
import '../../../../../food_delivery_client.dart';
class WLoginBody extends StatefulWidget {
const WLoginBody({super.key});
@override
State<WLoginBody> createState() => _WLoginBodyState();
}
class _WLoginBodyState extends State<WLoginBody> {
late TextEditingController _phoneNumberController;
late TextEditingController _passwordController;
final _formKey = GlobalKey<FormState>();
bool _isValidForm = false;
void _validateForm() {
final isValid = _formKey.currentState?.validate() ?? false;
if (isValid != _isValidForm) {
setState(() {
_isValidForm = isValid;
});
}
}
@override
void initState() {
_phoneNumberController = TextEditingController();
_passwordController = TextEditingController();
_passwordController.addListener(_validateForm);
_phoneNumberController.addListener(_validateForm);
super.initState();
}
@override
void dispose() {
_phoneNumberController.removeListener(_validateForm);
_passwordController.removeListener(_validateForm);
_phoneNumberController.dispose();
_passwordController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Form(
key: _formKey,
autovalidateMode: AutovalidateMode.onUserInteraction,
child: WLayout(
top: false,
left: false,
right: false,
child: Scaffold(
body: Stack(
children: [
SizedBox(
width: context.w,
child: SvgPicture.asset(AppIcons.icLogin, fit: BoxFit.fitWidth),
),
Positioned(
child: Material(
color: AppColors.cTransparent,
child: SingleChildScrollView(
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior.onDrag,
child:
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
30.verticalSpace,
//WBackButton(),
60.verticalSpace,
WelcomeText(
text: context.loc.welcome_to_volt(
AppLocaleKeys.appName,
),
),
8.verticalSpace,
Text(
context.loc.please_login,
style: AppTextStyles.size14Regular.copyWith(
color: AppColors.cA7AEC1,
height: 1.6,
),
),
54.verticalSpace,
Text(
context.loc.email_or_phone,
style: context.appThemeTextStyles.size16Medium,
),
10.verticalSpace,
AppTextFormField(
prefixIcon: Text("+ 998"),
controller: _phoneNumberController,
hintText: context.loc.enter_email_or_phone,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
Formatters.phoneFormatter,
LengthLimitingTextInputFormatter(12),
],
validator: (value) {
return Validators.validatePhoneNumber(
_phoneNumberController.text.trim(),
);
},
),
20.verticalSpace,
Text(
context.loc.password,
style: context.appThemeTextStyles.size16Medium,
),
10.verticalSpace,
AppTextFormField(
obscureText: true,
controller: _passwordController,
hintText: context.loc.enter_password,
validator: (value) {
return Validators.validatePassword(
_passwordController.text.trim(),
);
},
),
10.verticalSpace,
Align(
alignment: AlignmentGeometry.centerRight,
child: TextButton(
onPressed: () {},
child: Text(
context.loc.forgot_password,
style: AppTextStyles.size14Regular.copyWith(
color: AppColors.cFF6F00,
),
),
),
),
60.verticalSpace,
AppButton(
name: context.loc.login,
isActive: _isValidForm,
isLoading: false,
onPressed: () {
if (_formKey.currentState?.validate() ??
false) {}
},
),
15.verticalSpace,
Align(
alignment: AlignmentGeometry.center,
child: RichText(
text: TextSpan(
text: context.loc.dont_have_account,
style:
context.appThemeTextStyles.size14Regular,
children: [
WidgetSpan(
baseline: TextBaseline.alphabetic,
alignment: PlaceholderAlignment.baseline,
child: TextButton(
onPressed: () {},
style: ButtonStyle(
shadowColor: WidgetStatePropertyAll(
AppColors.cFF6F00.newWithOpacity(
.2,
),
),
padding: WidgetStatePropertyAll(
EdgeInsets.symmetric(horizontal: 4),
),
),
child: Text(
context.loc.register,
style: AppTextStyles.size14Bold
.copyWith(
color: AppColors.cFF6F00,
),
),
),
),
],
),
),
),
],
).paddingOnly(
left: 24,
right: 24,
top: context.mq.viewPadding.top,
bottom: context.mq.viewPadding.bottom,
),
),
),
),
],
),
),
),
);
}
}

View File

@@ -0,0 +1,16 @@
import 'package:food_delivery_client/feature/auth/presentation/blocs/login_bloc/login_bloc.dart';
import 'package:food_delivery_client/feature/auth/presentation/pages/login_page/widgets/login_body.dart';
import '../../../../../food_delivery_client.dart';
class LoginPage extends StatelessWidget {
const LoginPage({super.key});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => sl<LoginBloc>(),
child: WLoginBody(),
);
}
}

View File

@@ -0,0 +1,234 @@
import 'package:food_delivery_client/core/helpers/formatters.dart';
import 'package:food_delivery_client/core/helpers/validator_helpers.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/login_usecase.dart';
import 'package:food_delivery_client/feature/auth/presentation/pages/login_page/widgets/welcome_text.dart';
import 'package:food_delivery_client/feature/common/presentation/widgets/app_text_form_field.dart';
import '../../../../../../food_delivery_client.dart';
import '../../../blocs/login_bloc/login_bloc.dart';
class WLoginBody extends StatefulWidget {
const WLoginBody({super.key});
@override
State<WLoginBody> createState() => _WLoginBodyState();
}
class _WLoginBodyState extends State<WLoginBody> {
late TextEditingController _phoneNumberController;
late TextEditingController _passwordController;
final _formKey = GlobalKey<FormState>();
bool _isValidForm = false;
void _validateForm() {
final isValid = _formKey.currentState?.validate() ?? false;
if (isValid != _isValidForm) {
setState(() {
_isValidForm = isValid;
});
}
}
@override
void initState() {
_phoneNumberController = TextEditingController();
_passwordController = TextEditingController();
_passwordController.addListener(_validateForm);
_phoneNumberController.addListener(_validateForm);
super.initState();
}
@override
void dispose() {
_phoneNumberController.removeListener(_validateForm);
_passwordController.removeListener(_validateForm);
_phoneNumberController.dispose();
_passwordController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return BlocConsumer<LoginBloc, LoginState>(
listenWhen: (previous, current) => previous.status != current.status,
listener: (context, state) {
if (state.status.isLoaded()) {
context.go(Routes.main);
}
},
builder: (context, state) {
return Form(
key: _formKey,
autovalidateMode: AutovalidateMode.onUserInteraction,
child: WLayout(
top: false,
left: false,
right: false,
child: Scaffold(
body: Stack(
children: [
SizedBox(
width: context.w,
child: SvgPicture.asset(
AppIcons.icLogin,
fit: BoxFit.fitWidth,
),
),
Positioned(
child: Material(
color: AppColors.cTransparent,
child: SingleChildScrollView(
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior.onDrag,
child:
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
30.verticalSpace,
//WBackButton(),
60.verticalSpace,
WelcomeText(
text: context.loc.welcome_to_volt(
AppLocaleKeys.appName,
),
),
8.verticalSpace,
Text(
context.loc.please_login,
style: AppTextStyles.size14Regular.copyWith(
color: AppColors.cA7AEC1,
height: 1.6,
),
),
54.verticalSpace,
Text(
context.loc.email_or_phone,
style:
context.appThemeTextStyles.size16Medium,
),
10.verticalSpace,
AppTextFormField(
prefixIcon: Text("+ 998"),
controller: _phoneNumberController,
hintText: context.loc.enter_email_or_phone,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
Formatters.phoneFormatter,
LengthLimitingTextInputFormatter(12),
],
validator: (value) {
return Validators.validatePhoneNumber(
_phoneNumberController.text.trim(),
);
},
),
20.verticalSpace,
Text(
context.loc.password,
style:
context.appThemeTextStyles.size16Medium,
),
10.verticalSpace,
AppTextFormField(
obscureText: true,
controller: _passwordController,
hintText: context.loc.enter_password,
validator: (value) {
return Validators.validatePassword(
_passwordController.text.trim(),
);
},
),
10.verticalSpace,
Align(
alignment: AlignmentGeometry.centerRight,
child: TextButton(
onPressed: () {},
child: Text(
context.loc.forgot_password,
style: AppTextStyles.size14Regular
.copyWith(color: AppColors.cFF6F00),
),
),
),
60.verticalSpace,
AppButton(
name: context.loc.login,
isActive: _isValidForm,
isLoading: state.status.isLoading(),
onPressed: () {
if (_formKey.currentState?.validate() ??
false) {
context.read<LoginBloc>().add(
LoginEvent.login(
LoginParams(
password: _passwordController.text
.trim(),
phoneNumber:
"+998${_phoneNumberController.text.trim().replaceAll(" ", "")}",
),
),
);
}
},
),
15.verticalSpace,
Align(
alignment: AlignmentGeometry.center,
child: RichText(
text: TextSpan(
text: context.loc.dont_have_account,
style: context
.appThemeTextStyles
.size14Regular,
children: [
WidgetSpan(
baseline: TextBaseline.alphabetic,
alignment:
PlaceholderAlignment.baseline,
child: TextButton(
onPressed: () {},
style: ButtonStyle(
shadowColor:
WidgetStatePropertyAll(
AppColors.cFF6F00
.newWithOpacity(.2),
),
padding: WidgetStatePropertyAll(
EdgeInsets.symmetric(
horizontal: 4,
),
),
),
child: Text(
context.loc.register,
style: AppTextStyles.size14Bold
.copyWith(
color: AppColors.cFF6F00,
),
),
),
),
],
),
),
),
],
).paddingOnly(
left: 24,
right: 24,
top: context.mq.viewPadding.top,
bottom: context.mq.viewPadding.bottom,
),
),
),
),
],
),
),
),
);
},
);
}
}

View File

@@ -1,4 +1,5 @@
import '../../../../../food_delivery_client.dart';
import '../../../../../../food_delivery_client.dart';
class WelcomeText extends StatelessWidget { class WelcomeText extends StatelessWidget {
final String text; final String text;

View File

@@ -0,0 +1,10 @@
import '../../../../../food_delivery_client.dart';
class CartPage extends StatelessWidget {
const CartPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(body: Column(children: [Center(child: Text("Cart"))]));
}
}

View File

@@ -0,0 +1,94 @@
import 'package:flutter/material.dart';
import 'package:food_delivery_client/core/core.dart';
class GradientSwitch extends StatefulWidget {
final bool value;
final ValueChanged<bool> onChanged;
final double width;
final double height;
final Duration duration;
const GradientSwitch({
super.key,
required this.value,
required this.onChanged,
this.width = 48,
this.height = 26,
this.duration = const Duration(milliseconds: 250),
});
@override
State<GradientSwitch> createState() => _GradientSwitchState();
}
class _GradientSwitchState extends State<GradientSwitch>
with SingleTickerProviderStateMixin {
late bool _isOn;
@override
void initState() {
super.initState();
_isOn = widget.value;
}
@override
void didUpdateWidget(covariant GradientSwitch oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.value != widget.value) {
_isOn = widget.value;
}
}
void _toggle() {
setState(() => _isOn = !_isOn);
widget.onChanged(_isOn);
}
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: _toggle,
child: AnimatedContainer(
duration: widget.duration,
width: widget.width,
height: widget.height,
padding: const EdgeInsets.all(3),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(widget.height / 2),
gradient: _isOn
? LinearGradient(
colors: [AppColors.cFF6F00, AppColors.cFFAB40],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
)
: null,
color: _isOn ? null : context.appThemeColors.inActiveColor2,
),
child: Stack(
children: [
AnimatedAlign(
duration: widget.duration,
alignment: _isOn ? Alignment.centerRight : Alignment.centerLeft,
curve: Curves.easeInOut,
child: Container(
width: widget.height - 4,
height: widget.height - 4,
decoration: BoxDecoration(
color: AppColors.cFFFFFF,
borderRadius: BorderRadius.circular(widget.height / 2),
boxShadow: [
BoxShadow(
color: AppColors.c292F3D.newWithOpacity(.25),
blurRadius: 4,
offset: const Offset(0, 10),
),
],
),
),
),
],
),
),
);
}
}

View File

@@ -6,3 +6,4 @@ export 'w_custom_modal_bottom_sheet.dart';
export 'app_button.dart'; export 'app_button.dart';
export 'app_list_tile.dart'; export 'app_list_tile.dart';
export 'w_back_button.dart'; export 'w_back_button.dart';
export 'app_switch_button.dart';

View File

@@ -0,0 +1,10 @@
import '../../../../../food_delivery_client.dart';
class DiscoverPage extends StatelessWidget {
const DiscoverPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(body: Column(children: [Center(child: Text("Discover"))]));
}
}

View File

@@ -0,0 +1,10 @@
import '../../../../../food_delivery_client.dart';
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(body: Column(children: [Center(child: Text("Home"))]));
}
}

View File

@@ -0,0 +1,26 @@
import 'package:flutter/widgets.dart';
import 'package:food_delivery_client/core/core.dart';
import 'package:food_delivery_client/feature/discover/presentation/pages/descover_page/discover_page.dart';
import 'package:food_delivery_client/feature/home/presentation/pages/home_page/home_page.dart';
import 'package:food_delivery_client/feature/profile/presentation/pages/profile_page.dart';
import 'package:food_delivery_client/feature/transactions/presentation/pages/transactions_page/transactions_page.dart';
import '../../../cart/presentation/pages/cart_page/cart_page.dart';
mixin MainPageMixins {
final List<Widget> pages = [
HomePage(),
DiscoverPage(),
CartPage(),
TransactionsPage(),
ProfilePage(),
];
final List<String> activeIcons = [
AppIcons.icHome,
AppIcons.icDiscover,
AppIcons.icCart1,
AppIcons.icTransactions,
AppIcons.icProfile,
];
}

View File

@@ -0,0 +1,68 @@
import 'package:food_delivery_client/feature/main/presentation/pages/main_page/widgtes/w_bottom_navbar_item.dart';
import '../../../../../food_delivery_client.dart';
class MainPage extends StatelessWidget with MainPageMixins {
MainPage({super.key});
@override
Widget build(BuildContext context) {
final List<String> inActiveIcons = [
context.appThemeIcons.icHome,
context.appThemeIcons.icDiscover,
context.appThemeIcons.icCart1,
context.appThemeIcons.icTransactions,
context.appThemeIcons.icProfile,
];
final List<String> titles = [
context.loc.home,
context.loc.discover,
context.loc.cart,
context.loc.transactions,
context.loc.profile,
];
return BlocProvider(
create: (context) => sl<MainBloc>(),
child: BlocBuilder<MainBloc, MainState>(
builder: (context, state) {
return Scaffold(
body: IndexedStack(index: state.currentIndex, children: pages),
bottomNavigationBar: DecoratedBox(
decoration: BoxDecoration(
color: context.appThemeColors.iconColor,
boxShadow: [
BoxShadow(
blurStyle: BlurStyle.inner,
spreadRadius: 0,
color: AppColors.cA7AEC1.newWithOpacity(.15),
blurRadius: 80,
offset: const Offset(0, 4),
),
],
),
child: BottomNavigationBar(
onTap: (value) {
context.read<MainBloc>().add(MainEvent.loaded(value));
},
currentIndex: state.currentIndex,
items: List.generate(titles.length, (index) {
return BottomNavigationBarItem(
label: titles[index],
tooltip: "",
icon: WBottomNavbarItem(
iconPath: inActiveIcons[index],
activeIconPath: activeIcons[index],
title: titles[index],
isActive: index == state.currentIndex,
),
);
}),
),
),
);
},
),
);
}
}

View File

@@ -0,0 +1,56 @@
import '../../../../../../food_delivery_client.dart';
class WBottomNavbarItem extends StatelessWidget {
const WBottomNavbarItem({
super.key,
required this.iconPath,
required this.activeIconPath,
required this.title,
required this.isActive,
});
final String iconPath;
final String activeIconPath;
final String title;
final bool isActive;
@override
Widget build(BuildContext context) {
return Column(
children: [
SizedBox(
height: 24,
width: 24,
child: SvgPicture.asset(
isActive ? activeIconPath : iconPath,
fit: BoxFit.cover,
),
),
8.verticalSpace,
if (!isActive)
Text(
title,
style: AppTextStyles.size12Medium.copyWith(
height: 1.3,
color: context.appThemeColors.inActiveColor1,
),
),
if (isActive)
ShaderMask(
shaderCallback: (bounds) => AppUtils.kGradient.createShader(
Rect.fromLTWH(0, 0, bounds.width, bounds.height),
),
child: Text(
title,
style: AppTextStyles.size12Medium.copyWith(
height: 1.3,
color: isActive
? AppColors.cFFFFFF
: context.appThemeColors.inActiveColor1,
),
),
),
],
);
}
}

View File

@@ -19,7 +19,7 @@ class SplashBloc extends Bloc<SplashEvent, SplashState> {
final token = _storageService.getString(key: AppLocaleKeys.token); final token = _storageService.getString(key: AppLocaleKeys.token);
log("Token:$token"); log("Token:$token");
if (token != null) { if (token != null) {
emit(state.copyWith(status: RequestStatus.error)); emit(state.copyWith(status: RequestStatus.loaded));
} else { } else {
emit(state.copyWith(status: RequestStatus.error)); emit(state.copyWith(status: RequestStatus.error));
} }

View File

@@ -14,6 +14,10 @@ class SplashPage extends StatelessWidget {
if (state.status.isError()) { if (state.status.isError()) {
context.go(Routes.onBoarding); context.go(Routes.onBoarding);
} }
if (state.status.isLoaded()) {
context.go(Routes.main);
}
}, },
child: WLayout( child: WLayout(
bottom: false, bottom: false,

View File

@@ -0,0 +1,21 @@
import '../../../../../food_delivery_client.dart';
class ProfilePage extends StatelessWidget {
const ProfilePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Home"),
GradientSwitch(value:false, onChanged: (value) {
print(value);
}),
],
),
);
}
}

View File

@@ -0,0 +1,12 @@
import '../../../../../food_delivery_client.dart';
class TransactionsPage extends StatelessWidget {
const TransactionsPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(children: [Center(child: Text("transactions"))]),
);
}
}