Skip to content

Commit 71e7ff2

Browse files
committed
add showActionSheet
1 parent b7c12c2 commit 71e7ff2

File tree

9 files changed

+88
-22
lines changed

9 files changed

+88
-22
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.7
2+
* Add showActionSheet function
3+
* Update and improve some codes
4+
15
## 1.0.6
26
* Add Stack ViewCell widget
37

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ add this line to pubspec.yaml
3838

3939
dependencies:
4040

41-
housecode: ^1.0.6
41+
housecode: ^1.0.7
4242

4343

4444
```

example/pubspec.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
name: async
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "2.6.1"
10+
version: "2.8.2"
1111
boolean_selector:
1212
dependency: transitive
1313
description:
@@ -21,14 +21,14 @@ packages:
2121
name: characters
2222
url: "https://pub.dartlang.org"
2323
source: hosted
24-
version: "1.1.0"
24+
version: "1.2.0"
2525
charcode:
2626
dependency: transitive
2727
description:
2828
name: charcode
2929
url: "https://pub.dartlang.org"
3030
source: hosted
31-
version: "1.2.0"
31+
version: "1.3.1"
3232
clock:
3333
dependency: transitive
3434
description:
@@ -80,7 +80,7 @@ packages:
8080
path: ".."
8181
relative: true
8282
source: path
83-
version: "1.0.6"
83+
version: "1.0.7"
8484
intl:
8585
dependency: transitive
8686
description:
@@ -94,14 +94,14 @@ packages:
9494
name: matcher
9595
url: "https://pub.dartlang.org"
9696
source: hosted
97-
version: "0.12.10"
97+
version: "0.12.11"
9898
meta:
9999
dependency: transitive
100100
description:
101101
name: meta
102102
url: "https://pub.dartlang.org"
103103
source: hosted
104-
version: "1.3.0"
104+
version: "1.7.0"
105105
path:
106106
dependency: transitive
107107
description:
@@ -155,7 +155,7 @@ packages:
155155
name: test_api
156156
url: "https://pub.dartlang.org"
157157
source: hosted
158-
version: "0.3.0"
158+
version: "0.4.3"
159159
typed_data:
160160
dependency: transitive
161161
description:
@@ -176,7 +176,7 @@ packages:
176176
name: vector_math
177177
url: "https://pub.dartlang.org"
178178
source: hosted
179-
version: "2.1.0"
179+
version: "2.1.1"
180180
sdks:
181-
dart: ">=2.12.0 <3.0.0"
181+
dart: ">=2.14.0 <3.0.0"
182182
flutter: ">=2.0.0"

lib/widgets/checkbox.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66

77
import 'package:flutter/cupertino.dart';
8-
import 'package:flutter/material.dart';
98

109
/// checkbox widget with cupertino style
1110
// ignore: must_be_immutable

lib/widgets/dialogs.dart

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,3 +342,68 @@ void showDatePicker(
342342
},
343343
);
344344
}
345+
346+
void showActionSheet(
347+
BuildContext context,
348+
List<String> items, {
349+
PickerItemSelected? itemSelected,
350+
bool useLight = true,
351+
Color textColor = Colors.black,
352+
String? title,
353+
String? message,
354+
}) {
355+
var views = (c) => items
356+
.map((item) => CupertinoActionSheetAction(
357+
child: Center(
358+
child: Text(
359+
item,
360+
style: TextStyle(color: textColor),
361+
),
362+
),
363+
onPressed: () {
364+
if (itemSelected != null) itemSelected(items.indexOf(item));
365+
Navigator.pop(c);
366+
},
367+
))
368+
.toList();
369+
370+
var picker = (c) => CupertinoActionSheet(
371+
actions: views(c),
372+
title: title == null
373+
? null
374+
: Text(
375+
title,
376+
style: TextStyle(
377+
color: textColor,
378+
fontWeight: FontWeight.bold,
379+
),
380+
),
381+
message: message == null
382+
? null
383+
: Text(
384+
message,
385+
textAlign: TextAlign.center,
386+
style: TextStyle(
387+
color: textColor,
388+
),
389+
),
390+
cancelButton: CupertinoActionSheetAction(
391+
child: Text(
392+
"Cancel",
393+
style: TextStyle(color: textColor),
394+
),
395+
onPressed: () {
396+
Navigator.pop(c);
397+
},
398+
),
399+
);
400+
401+
showCupertinoModalPopup(
402+
context: context,
403+
builder: (c) {
404+
return useLight
405+
? Theme(data: ThemeData.light(), child: picker(c))
406+
: picker(c);
407+
},
408+
);
409+
}

lib/widgets/loading_dialog.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
createTime:2021-08-26 19:15
55
*/
66

7-
import 'package:flutter/cupertino.dart';
87
import 'package:flutter/material.dart';
98

109
import 'package:housecode/widgets/circular_indicator.dart';

lib/widgets/text_cell.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
createTime:2021-08-26 19:15
55
*/
66

7-
import 'package:flutter/cupertino.dart';
87
import 'package:flutter/material.dart';
98

109
import 'package:housecode/widgets/view_cell.dart';

pubspec.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
name: async
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "2.6.1"
10+
version: "2.8.2"
1111
boolean_selector:
1212
dependency: transitive
1313
description:
@@ -21,14 +21,14 @@ packages:
2121
name: characters
2222
url: "https://pub.dartlang.org"
2323
source: hosted
24-
version: "1.1.0"
24+
version: "1.2.0"
2525
charcode:
2626
dependency: transitive
2727
description:
2828
name: charcode
2929
url: "https://pub.dartlang.org"
3030
source: hosted
31-
version: "1.2.0"
31+
version: "1.3.1"
3232
clock:
3333
dependency: transitive
3434
description:
@@ -87,14 +87,14 @@ packages:
8787
name: matcher
8888
url: "https://pub.dartlang.org"
8989
source: hosted
90-
version: "0.12.10"
90+
version: "0.12.11"
9191
meta:
9292
dependency: transitive
9393
description:
9494
name: meta
9595
url: "https://pub.dartlang.org"
9696
source: hosted
97-
version: "1.3.0"
97+
version: "1.7.0"
9898
path:
9999
dependency: transitive
100100
description:
@@ -148,7 +148,7 @@ packages:
148148
name: test_api
149149
url: "https://pub.dartlang.org"
150150
source: hosted
151-
version: "0.3.0"
151+
version: "0.4.3"
152152
typed_data:
153153
dependency: transitive
154154
description:
@@ -169,7 +169,7 @@ packages:
169169
name: vector_math
170170
url: "https://pub.dartlang.org"
171171
source: hosted
172-
version: "2.1.0"
172+
version: "2.1.1"
173173
sdks:
174-
dart: ">=2.12.0 <3.0.0"
174+
dart: ">=2.14.0 <3.0.0"
175175
flutter: ">=2.0.0"

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: housecode
22
description: A set of extensions and widgets by Housecode.Net to simplify some function and re-useable widgets.
3-
version: 1.0.6
3+
version: 1.0.7
44
homepage: https://github.com/housecode/housecode_flutter
55

66
environment:

0 commit comments

Comments
 (0)