From bf5cc505ed7c0ab7e202c31066c9cabc30098b32 Mon Sep 17 00:00:00 2001 From: User3 Date: Mon, 26 May 2025 16:24:19 +0300 Subject: [PATCH] #sprint-1 --- assets/closed-eye.svg | 10 ++++ assets/eye.svg | 11 ++++ example/assets/closed-eye.svg | 10 ++++ example/assets/eye.svg | 11 ++++ example/lib/inputs_section.dart | 17 +++--- example/lib/search_section.dart | 2 +- example/pubspec.lock | 8 +++ example/pubspec.yaml | 1 + lib/input.dart | 32 +++++++++--- lib/tabbar.dart | 91 +++++++++++++++++---------------- pubspec.yaml | 1 + 11 files changed, 136 insertions(+), 58 deletions(-) create mode 100644 assets/closed-eye.svg create mode 100644 assets/eye.svg create mode 100644 example/assets/closed-eye.svg create mode 100644 example/assets/eye.svg diff --git a/assets/closed-eye.svg b/assets/closed-eye.svg new file mode 100644 index 0000000..0906817 --- /dev/null +++ b/assets/closed-eye.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/assets/eye.svg b/assets/eye.svg new file mode 100644 index 0000000..83366c6 --- /dev/null +++ b/assets/eye.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/example/assets/closed-eye.svg b/example/assets/closed-eye.svg new file mode 100644 index 0000000..0906817 --- /dev/null +++ b/example/assets/closed-eye.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/example/assets/eye.svg b/example/assets/eye.svg new file mode 100644 index 0000000..83366c6 --- /dev/null +++ b/example/assets/eye.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/example/lib/inputs_section.dart b/example/lib/inputs_section.dart index 11cc71b..0aaefe0 100644 --- a/example/lib/inputs_section.dart +++ b/example/lib/inputs_section.dart @@ -11,13 +11,15 @@ class InputsSection extends StatefulWidget { class _InputsSectionState extends State { static final inputsList = [ {"initText": ""}, - {"initText": "Ivan"}, - {"initText": "", 'label': "Name"}, + {"initText": "Введите имя"}, + {"initText": "", 'label': "Введите имя"}, {"initText": "", 'isError': "true"}, - {'label': "Name"}, - {"initText": "Enter Name", 'label': "Name"}, + {'label': "Введите имя"}, + {"initText": "Введите имя", 'label': "Введите имя"}, {"initText": "*********", 'isPassword': "true"}, + {'isMask': 'true', 'initText': ""}, ]; + @override Widget build(BuildContext context) { return Container( @@ -33,10 +35,13 @@ class _InputsSectionState extends State { child: InputWidget( controller: TextEditingController(text: currentItem['initText']), label: currentItem['label'], - hintText: 'Введите имя', + hintText: currentItem['isMask'] == 'true' + ? '--.--.----' + : 'Введите имя', isError: currentItem['isError'] ?? "", - errorText: 'Enter your name', + errorText: 'Введите имя', isPassword: currentItem['isPassword'], + isMask: currentItem['isMask'], ), ); }, diff --git a/example/lib/search_section.dart b/example/lib/search_section.dart index a9cfc7b..1b4a4a7 100644 --- a/example/lib/search_section.dart +++ b/example/lib/search_section.dart @@ -24,7 +24,7 @@ class _SearchSectionState extends State { margin: EdgeInsets.only(bottom: height(context) * 3), child: SearchWidget( controller: controller, - hintText: 'Search', + hintText: 'Искать описание', isClosable: currentValue, ), ); diff --git a/example/pubspec.lock b/example/pubspec.lock index 3887b7b..a1fe29f 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -147,6 +147,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.1.1" + mask_text_input_formatter: + dependency: "direct main" + description: + name: mask_text_input_formatter + sha256: "978c58ec721c25621ceb468e633f4eef64b64d45424ac4540e0565d4f7c800cd" + url: "https://pub.dev" + source: hosted + version: "2.9.0" matcher: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index a5937ef..d3c45fd 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -11,6 +11,7 @@ dependencies: flutter: sdk: flutter flutter_advanced_switch: ^3.1.0 + mask_text_input_formatter: ^2.9.0 modal_bottom_sheet: ^3.0.0 ui_kit: path: .. diff --git a/lib/input.dart b/lib/input.dart index 9558502..4705e84 100644 --- a/lib/input.dart +++ b/lib/input.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:mask_text_input_formatter/mask_text_input_formatter.dart'; import 'package:ui_kit/ui_kit.dart'; class InputWidget extends StatefulWidget { @@ -10,6 +12,7 @@ class InputWidget extends StatefulWidget { this.isError = 'false', this.errorText, this.isPassword = 'false', + this.isMask = 'false', }); final TextEditingController controller; final String? label; @@ -17,6 +20,7 @@ class InputWidget extends StatefulWidget { final String isError; final String? errorText; final String? isPassword; + final String? isMask; @override State createState() => _InputWidgetState(); @@ -30,6 +34,12 @@ class _InputWidgetState extends State { widget.isPassword == 'true' ? obscureText = true : obscureText = false; } + var maskFormatter = MaskTextInputFormatter( + mask: '+# (###) ###-##-##', + filter: {"#": RegExp(r'[0-9]')}, + type: MaskAutoCompletionType.lazy, + ); + @override Widget build(BuildContext context) { return Column( @@ -51,6 +61,8 @@ class _InputWidgetState extends State { height: 48, child: TextFormField( controller: widget.controller, + obscureText: obscureText, + inputFormatters: widget.isMask == 'true' ? [maskFormatter] : [], decoration: InputDecoration( fillColor: widget.isError == 'true' ? errorBgColor : inputBgColor, filled: true, @@ -59,13 +71,19 @@ class _InputWidgetState extends State { vertical: 14, ), hintText: widget.hintText, - suffix: widget.isPassword == 'true' - ? Image.asset( - width: 20, - height: 20, - obscureText == true - ? 'assets/hidden.png' - : 'assets/hidden.png', + suffixIcon: widget.isPassword == 'true' + ? IconButton( + onPressed: () { + setState(() { + obscureText = !obscureText; + }); + }, + icon: SvgPicture.asset( + fit: BoxFit.none, + obscureText != true + ? 'assets/eye.svg' + : 'assets/closed-eye.svg', + ), ) : null, hintStyle: textRegular.copyWith(color: captionColor), diff --git a/lib/tabbar.dart b/lib/tabbar.dart index 5acaf0f..cab9c86 100644 --- a/lib/tabbar.dart +++ b/lib/tabbar.dart @@ -19,54 +19,57 @@ class _TabBarWidgetState extends State { @override Widget build(BuildContext context) { - return BottomNavigationBar( - showSelectedLabels: true, - showUnselectedLabels: true, - selectedLabelStyle: caption2Regular, - unselectedLabelStyle: caption2Regular, - type: BottomNavigationBarType.fixed, - unselectedItemColor: iconsColor, - items: [ - BottomNavigationBarItem( - icon: Image.asset('assets/home.png', width: 18, height: 20), - label: 'Главная', - activeIcon: Image.asset( - 'assets/home-active.png', - width: 18, - height: 20, + return SizedBox( + height: 51, + child: BottomNavigationBar( + showSelectedLabels: true, + showUnselectedLabels: true, + selectedLabelStyle: caption2Regular, + unselectedLabelStyle: caption2Regular, + type: BottomNavigationBarType.fixed, + unselectedItemColor: iconsColor, + items: [ + BottomNavigationBarItem( + icon: Image.asset('assets/home.png', width: 18, height: 20), + label: 'Главная', + activeIcon: Image.asset( + 'assets/home-active.png', + width: 18, + height: 20, + ), ), - ), - BottomNavigationBarItem( - icon: Image.asset('assets/results.png', width: 18, height: 20), - label: 'Каталог', - activeIcon: Image.asset( - 'assets/results-active.png', - width: 18, - height: 20, + BottomNavigationBarItem( + icon: Image.asset('assets/results.png', width: 18, height: 20), + label: 'Каталог', + activeIcon: Image.asset( + 'assets/results-active.png', + width: 18, + height: 20, + ), ), - ), - BottomNavigationBarItem( - icon: Image.asset('assets/projects.png', width: 18, height: 20), - label: 'Проекты', - activeIcon: Image.asset( - 'assets/projects-active.png', - width: 18, - height: 20, + BottomNavigationBarItem( + icon: Image.asset('assets/projects.png', width: 18, height: 20), + label: 'Проекты', + activeIcon: Image.asset( + 'assets/projects-active.png', + width: 18, + height: 20, + ), ), - ), - BottomNavigationBarItem( - icon: Image.asset('assets/profile.png', width: 18, height: 20), - label: 'Профиль', - activeIcon: Image.asset( - 'assets/profile-active.png', - width: 18, - height: 20, + BottomNavigationBarItem( + icon: Image.asset('assets/profile.png', width: 18, height: 20), + label: 'Профиль', + activeIcon: Image.asset( + 'assets/profile-active.png', + width: 18, + height: 20, + ), ), - ), - ], - currentIndex: _selectedIndex, - selectedItemColor: primaryColor, - onTap: _onItemTapped, + ], + currentIndex: _selectedIndex, + selectedItemColor: primaryColor, + onTap: _onItemTapped, + ), ); } } diff --git a/pubspec.yaml b/pubspec.yaml index 5b26e21..b0925a4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,6 +13,7 @@ dependencies: sdk: flutter flutter_advanced_switch: ^3.1.0 flutter_svg: ^2.1.0 + mask_text_input_formatter: ^2.9.0 modal_bottom_sheet: ^3.0.0 dev_dependencies: