Skip to content

Commit 811ba72

Browse files
committed
version 0.4.0
1 parent 9a6fd8f commit 811ba72

File tree

10 files changed

+452
-6
lines changed

10 files changed

+452
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.4.0] - 2020.1.28
2+
3+
- Added `MongolAlertDialog`.
4+
15
## [0.3.2] - 2020.1.28
26

37
- Fixed bug: Spaces after a newline character caused newline char to be inserted in ParagraphBuilder.

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
# mongol
22

3-
Widgets for vertical Mongolian
3+
This library is a collection of Flutter widgets for displaying traditional Mongolian vertical text.
44

55
## Contents
66

7-
Currently this project contains the following widget:
7+
Currently this project contains the following widgets:
88

9-
- `MongolText`: A vertical version of Text.
9+
- `MongolText`
10+
- `MongolAlertDialog`
1011

11-
Left-to-right line wrapping is supported.
12+
### MongolText
13+
14+
This is a vertical text version of Flutter's `Text` widget. Left-to-right line wrapping is supported.
1215

1316
<img src="https://github.com/suragch/mongol/blob/master/example/supplemental/mongol_demo.png" width="200">
1417

18+
### MongolAlertDialog
19+
20+
This alert dialog works mostly the same as the Flutter `AlertDialog`.
21+
22+
<img src="https://github.com/suragch/mongol/blob/master/example/supplemental/mongol_alert_dialog.png" width="200">
23+
1524
## TODO
1625

1726
- Add text styling and expose `MongolRichText`.

example/lib/alert_dialog_demo.dart

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:mongol/mongol.dart';
3+
4+
class AlertDialogDemo extends StatelessWidget {
5+
@override
6+
Widget build(BuildContext context) {
7+
return Scaffold(
8+
body: Center(
9+
child: RaisedButton(
10+
child: Text('Show Dialog'),
11+
onPressed: () {
12+
showAlertDialog(context);
13+
},
14+
),
15+
),
16+
);
17+
}
18+
}
19+
20+
showAlertDialog(BuildContext context) {
21+
// set up the buttons
22+
Widget actionButton = FlatButton(
23+
child: MongolText("ᠮᠡᠳᠡᠭᠰᠡᠨ"),
24+
onPressed: () {},
25+
);
26+
27+
// set up the AlertDialog
28+
MongolAlertDialog alert = MongolAlertDialog(
29+
title: MongolText("ᠠᠰᠠᠭᠤᠳᠠᠯ ᠲᠠᠢ"),
30+
content: MongolText("ᠬᠣᠯᠪᠣᠭᠳᠠᠬᠤ ᠪᠣᠯᠤᠮᠵᠢ ᠦᠭᠡᠢ ᠪᠠᠶᠢᠨ᠎ᠠ"),
31+
actions: [
32+
actionButton,
33+
],
34+
);
35+
36+
// show the dialog
37+
showDialog(
38+
context: context,
39+
builder: (BuildContext context) {
40+
return alert;
41+
},
42+
);
43+
}

example/lib/main.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:mongol_demo_app/text_demo.dart';
3+
import 'package:mongol_demo_app/alert_dialog_demo.dart';
34

45
void main() => runApp(DemoApp());
56

@@ -33,6 +34,15 @@ class HomeScreen extends StatelessWidget {
3334
);
3435
},
3536
),
37+
ListTile(
38+
title: Text('MongolAlertDialog'),
39+
onTap: () {
40+
Navigator.push(
41+
context,
42+
MaterialPageRoute(builder: (context) => AlertDialogDemo()),
43+
);
44+
},
45+
),
3646
],
3747
);
3848
}

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ packages:
9494
path: ".."
9595
relative: true
9696
source: path
97-
version: "0.3.1"
97+
version: "0.4.0"
9898
path:
9999
dependency: transitive
100100
description:
49.5 KB
Loading

lib/mongol.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
library mongol;
22

33
export 'package:mongol/mongol_text.dart';
4+
export 'package:mongol/mongol_alert_dialog.dart';

lib/mongol_alert_dialog.dart

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
import 'package:flutter/material.dart';
2+
3+
import 'mongol_button_bar.dart';
4+
5+
/// This class was adapted from Flutter [Dialog]
6+
class MongolDialog extends StatelessWidget {
7+
const MongolDialog({
8+
Key key,
9+
this.backgroundColor,
10+
this.elevation,
11+
this.insetAnimationDuration = const Duration(milliseconds: 100),
12+
this.insetAnimationCurve = Curves.decelerate,
13+
this.shape,
14+
this.child,
15+
}) : super(key: key);
16+
17+
final Color backgroundColor;
18+
final double elevation;
19+
final Duration insetAnimationDuration;
20+
final Curve insetAnimationCurve;
21+
final ShapeBorder shape;
22+
final Widget child;
23+
24+
static const RoundedRectangleBorder _defaultDialogShape =
25+
RoundedRectangleBorder(
26+
borderRadius: BorderRadius.all(Radius.circular(2.0)));
27+
static const double _defaultElevation = 24.0;
28+
29+
@override
30+
Widget build(BuildContext context) {
31+
final DialogTheme dialogTheme = DialogTheme.of(context);
32+
return AnimatedPadding(
33+
padding: MediaQuery.of(context).viewInsets +
34+
const EdgeInsets.symmetric(horizontal: 24.0, vertical: 40.0),
35+
duration: insetAnimationDuration,
36+
curve: insetAnimationCurve,
37+
child: MediaQuery.removeViewInsets(
38+
removeLeft: true,
39+
removeTop: true,
40+
removeRight: true,
41+
removeBottom: true,
42+
context: context,
43+
child: Center(
44+
child: ConstrainedBox(
45+
constraints: const BoxConstraints(minHeight: 280.0),
46+
child: Material(
47+
color: backgroundColor ??
48+
dialogTheme.backgroundColor ??
49+
Theme.of(context).dialogBackgroundColor,
50+
elevation:
51+
elevation ?? dialogTheme.elevation ?? _defaultElevation,
52+
shape: shape ?? dialogTheme.shape ?? _defaultDialogShape,
53+
type: MaterialType.card,
54+
child: child,
55+
),
56+
),
57+
),
58+
),
59+
);
60+
}
61+
}
62+
63+
/// This class was adapted from the Flutter [AlertDialog] class
64+
class MongolAlertDialog extends StatelessWidget {
65+
const MongolAlertDialog({
66+
Key key,
67+
this.title,
68+
this.titlePadding,
69+
this.titleTextStyle,
70+
this.content,
71+
this.contentPadding = const EdgeInsets.fromLTRB(24.0, 20.0, 24.0, 24.0),
72+
this.contentTextStyle,
73+
this.actions,
74+
this.actionsPadding = EdgeInsets.zero,
75+
this.actionsOverflowDirection,
76+
this.buttonPadding,
77+
this.backgroundColor,
78+
this.elevation,
79+
this.shape,
80+
}) : assert(contentPadding != null),
81+
super(key: key);
82+
83+
final Widget title;
84+
final EdgeInsetsGeometry titlePadding;
85+
final TextStyle titleTextStyle;
86+
final Widget content;
87+
final EdgeInsetsGeometry contentPadding;
88+
final TextStyle contentTextStyle;
89+
final List<Widget> actions;
90+
final EdgeInsetsGeometry actionsPadding;
91+
final VerticalDirection actionsOverflowDirection;
92+
final EdgeInsetsGeometry buttonPadding;
93+
final Color backgroundColor;
94+
final double elevation;
95+
final ShapeBorder shape;
96+
97+
@override
98+
Widget build(BuildContext context) {
99+
final ThemeData theme = Theme.of(context);
100+
final DialogTheme dialogTheme = DialogTheme.of(context);
101+
102+
Widget titleWidget;
103+
Widget contentWidget;
104+
Widget actionsWidget;
105+
if (title != null)
106+
titleWidget = Padding(
107+
padding: titlePadding ??
108+
EdgeInsets.fromLTRB(24.0, 24.0, 24.0, content == null ? 20.0 : 0.0),
109+
child: DefaultTextStyle(
110+
style: titleTextStyle ??
111+
dialogTheme.titleTextStyle ??
112+
theme.textTheme.headline6,
113+
child: Semantics(
114+
child: title,
115+
namesRoute: true,
116+
container: true,
117+
),
118+
),
119+
);
120+
121+
if (content != null)
122+
contentWidget = Padding(
123+
padding: contentPadding,
124+
child: DefaultTextStyle(
125+
style: contentTextStyle ??
126+
dialogTheme.contentTextStyle ??
127+
theme.textTheme.subtitle1,
128+
child: content,
129+
),
130+
);
131+
132+
if (actions != null)
133+
actionsWidget = Padding(
134+
padding: actionsPadding,
135+
child: MongolButtonBar(
136+
buttonPadding: buttonPadding,
137+
children: actions,
138+
),
139+
);
140+
141+
List<Widget> rowChildren;
142+
143+
rowChildren = <Widget>[
144+
if (title != null || content != null)
145+
Flexible(
146+
child: Row(
147+
mainAxisSize: MainAxisSize.min,
148+
crossAxisAlignment: CrossAxisAlignment.stretch,
149+
children: <Widget>[
150+
if (title != null) titleWidget,
151+
if (content != null) contentWidget,
152+
],
153+
),
154+
),
155+
if (actions != null) actionsWidget,
156+
];
157+
158+
Widget dialogChild = IntrinsicHeight(
159+
child: Row(
160+
mainAxisSize: MainAxisSize.min,
161+
crossAxisAlignment: CrossAxisAlignment.stretch,
162+
children: rowChildren,
163+
),
164+
);
165+
166+
return MongolDialog(
167+
backgroundColor: backgroundColor,
168+
elevation: elevation,
169+
shape: shape,
170+
child: dialogChild,
171+
);
172+
}
173+
}

0 commit comments

Comments
 (0)