-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoading.dart
73 lines (70 loc) · 2.28 KB
/
Loading.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import './setTimeout.dart';
import './CreateLayer.dart';
import 'dart:async';
const Color _backgroundColor = Color.fromRGBO(0, 0, 0, 0.9);
const Color _activeColor = Color.fromRGBO(255,255,255, 1);
class Loading {
static CreateLayer _cty = new CreateLayer(false);
static Timer _timer;
static Function _update;
static close () {
_update = null;
_cty.close();
}
static Future show (BuildContext context, String msg, [int duration = 15000]) async {
_timer?.cancel();
_timer = setTimeout(close, duration);
if(_update!=null) {
_update(msg);
} else {
await _cty.show(
context: context,
builder: (ctx, constraints) {
String message = msg;
return StatefulBuilder(
builder: (context, state) {
_update = ((String newMessage){
state(() {
message = newMessage;
});
});
return new Center(
child: Container(
decoration: new BoxDecoration(
color: _backgroundColor,
borderRadius: BorderRadius.circular(5),
),
margin: EdgeInsets.all(30.0),
padding: EdgeInsets.all(20.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new SizedBox(
width: 30.0,
height: 30.0,
child: new CircularProgressIndicator(
strokeWidth: 2.0,
valueColor: AlwaysStoppedAnimation(_activeColor)
)
),
Padding(
padding: EdgeInsets.fromLTRB(0, 5.0, 0, 0),
child: Text(message, style: new TextStyle(
color: _activeColor,
fontSize: 14.0,
decoration: TextDecoration.none,
)),
)
]
)
)
);
},
);
}
);
}
}
}