Skip to content

Commit 3db50b8

Browse files
authored
Add PasswordBox widget (#795) @WinXaito
Add PasswordBox widget
2 parents 9e5bae4 + c76a410 commit 3db50b8

15 files changed

Lines changed: 549 additions & 17 deletions

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [next]
2+
3+
- Add parameters `onTapDown` and `onTapUp` on all buttons. ([#795](https://github.com/bdlukaa/fluent_ui/pull/795))
4+
- **Breaking: if you use the abstract class `BaseButton`, these two parameters are now required**
5+
- Add `PasswordBox` widget. ([#795](https://github.com/bdlukaa/fluent_ui/pull/795))
6+
17
## 4.4.2
28

39
- Add `NumberBox` widget. ([#560](https://github.com/bdlukaa/fluent_ui/issues/560) [#771](https://github.com/bdlukaa/fluent_ui/pull/771) [#789](https://github.com/bdlukaa/fluent_ui/pull/789))
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// Generated file. Do not edit.
3+
//
4+
5+
// ignore_for_file: directives_ordering
6+
// ignore_for_file: lines_longer_than_80_chars
7+
// ignore_for_file: depend_on_referenced_packages
8+
9+
import 'package:flutter_native_splash/flutter_native_splash_web.dart';
10+
import 'package:system_theme_web/system_theme_web.dart';
11+
import 'package:url_launcher_web/url_launcher_web.dart';
12+
13+
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
14+
15+
// ignore: public_member_api_docs
16+
void registerPlugins(Registrar registrar) {
17+
FlutterNativeSplashWeb.registerWith(registrar);
18+
SystemThemeWeb.registerWith(registrar);
19+
UrlLauncherPlugin.registerWith(registrar);
20+
registrar.registerMessageHandler();
21+
}

example/lib/main.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ void main() async {
7272

7373
class MyApp extends StatelessWidget {
7474
const MyApp({Key? key}) : super(key: key);
75+
7576
// private navigators
7677

7778
@override
@@ -250,6 +251,17 @@ class _MyHomePageState extends State<MyHomePage> with WindowListener {
250251
}
251252
},
252253
),
254+
PaneItem(
255+
key: const Key('/forms/passwordbox'),
256+
icon: const Icon(FluentIcons.password_field),
257+
title: const Text('PasswordBox'),
258+
body: const SizedBox.shrink(),
259+
onTap: () {
260+
if (router.location != '/forms/passwordbox') {
261+
router.pushNamed('forms_passwordbox');
262+
}
263+
},
264+
),
253265
PaneItem(
254266
key: const Key('/forms/time_picker'),
255267
icon: const Icon(FluentIcons.time_picker),
@@ -872,6 +884,15 @@ final router = GoRouter(
872884
),
873885
),
874886

887+
GoRoute(
888+
path: '/forms/passwordbox',
889+
name: 'forms_passwordbox',
890+
builder: (context, state) => DeferredWidget(
891+
forms.loadLibrary,
892+
() => forms.PasswordBoxPage(),
893+
),
894+
),
895+
875896
/// TimePicker
876897
GoRoute(
877898
path: '/forms/time_picker',

example/lib/routes/forms.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export '../screens/forms/auto_suggest_box.dart';
22
export '../screens/forms/combobox.dart';
33
export '../screens/forms/number_box.dart';
4+
export '../screens/forms/password_box.dart';
45
export '../screens/forms/date_picker.dart';
56
export '../screens/forms/text_box.dart';
67
export '../screens/forms/time_picker.dart';
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import 'package:example/widgets/card_highlight.dart';
2+
import 'package:example/widgets/page.dart';
3+
import 'package:fluent_ui/fluent_ui.dart';
4+
5+
class PasswordBoxPage extends StatefulWidget {
6+
const PasswordBoxPage({super.key});
7+
8+
@override
9+
State<PasswordBoxPage> createState() => _PasswordBoxPageState();
10+
}
11+
12+
class _PasswordBoxPageState extends State<PasswordBoxPage> with PageMixin {
13+
bool disabled = false;
14+
PasswordRevealMode revealMode = PasswordRevealMode.peek;
15+
16+
@override
17+
Widget build(BuildContext context) {
18+
return ScaffoldPage.scrollable(
19+
header: PageHeader(
20+
title: const Text('NumberBox'),
21+
commandBar: ToggleSwitch(
22+
checked: disabled,
23+
onChanged: (v) {
24+
setState(() => disabled = v);
25+
},
26+
content: const Text('Disabled'),
27+
),
28+
),
29+
children: [
30+
const Text(
31+
'The PasswordBox is almost identical to the TextBox. But the character'
32+
' is obfuscated by default and a button in the suffix allow the user to '
33+
'show briefly the password in plain text.',
34+
),
35+
subtitle(
36+
content: const Text('A simple PasswordBox in peek mode (default)')),
37+
CardHighlight(
38+
child: Row(children: [
39+
Expanded(
40+
child: PasswordBox(
41+
enabled: !disabled,
42+
)),
43+
]),
44+
codeSnippet: '''PasswordBox()''',
45+
),
46+
subtitle(
47+
content: const Text('A simple PasswordBox in peekAlways mode')),
48+
CardHighlight(
49+
child: Row(children: [
50+
Expanded(
51+
child: PasswordBox(
52+
enabled: !disabled,
53+
revealMode: PasswordRevealMode.peekAlways,
54+
)),
55+
]),
56+
codeSnippet: '''PasswordBox(
57+
revealMode: PasswordRevealMode.peekAlways,
58+
)''',
59+
),
60+
subtitle(
61+
content: const Text(
62+
'A simple PasswordBox in visible (left) and hidden (right) mode')),
63+
CardHighlight(
64+
child: Row(children: [
65+
Expanded(
66+
child: PasswordBox(
67+
enabled: !disabled,
68+
revealMode: PasswordRevealMode.visible,
69+
placeholder: 'Visible Password',
70+
)),
71+
const SizedBox(width: 10.0),
72+
Expanded(
73+
child: PasswordBox(
74+
enabled: !disabled,
75+
revealMode: PasswordRevealMode.hidden,
76+
placeholder: 'Hidden Password',
77+
),
78+
)
79+
]),
80+
codeSnippet: '''PasswordBox(
81+
revealMode: PasswordRevealMode.visible,
82+
);
83+
84+
PasswordBox(
85+
revealMode: PasswordRevealMode.hidden,
86+
);''',
87+
),
88+
subtitle(content: const Text('Update programmatically the visibility')),
89+
CardHighlight(
90+
child: Row(children: [
91+
Expanded(
92+
child: PasswordBox(
93+
enabled: !disabled,
94+
revealMode: revealMode,
95+
),
96+
),
97+
const SizedBox(width: 10),
98+
SizedBox(
99+
// width: 50,
100+
child: ComboBox<PasswordRevealMode>(
101+
onChanged: (e) {
102+
setState(() {
103+
revealMode = e ?? PasswordRevealMode.peek;
104+
});
105+
},
106+
value: revealMode,
107+
items: PasswordRevealMode.values.map((e) {
108+
return ComboBoxItem(child: Text(e.name), value: e);
109+
}).toList(),
110+
),
111+
),
112+
]),
113+
codeSnippet: '''PasswordBox(
114+
revealMode: revealMode,
115+
)''',
116+
),
117+
],
118+
);
119+
}
120+
}

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,5 +587,5 @@ packages:
587587
source: hosted
588588
version: "3.1.1"
589589
sdks:
590-
dart: ">=2.18.5 <4.0.0"
590+
dart: ">=2.18.5 <3.0.0"
591591
flutter: ">=3.7.0"

lib/fluent_ui.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export 'src/controls/form/auto_suggest_box.dart';
4747
export 'src/controls/form/combo_box.dart';
4848
export 'src/controls/form/form_row.dart';
4949
export 'src/controls/form/number_box.dart';
50+
export 'src/controls/form/password_box.dart';
5051
export 'src/controls/form/pickers/date_picker.dart';
5152
export 'src/controls/form/pickers/time_picker.dart';
5253
export 'src/controls/form/selection_controls.dart';

0 commit comments

Comments
 (0)