fix hot reload

This commit is contained in:
Salvatore Giordano
2021-02-15 15:40:35 +01:00
parent 870f1e43a3
commit 2e7e66f8cf
4 changed files with 123 additions and 62 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
c081df5f4486e48f68cf5c318dc003f2 c3757524e06ced55f3d1b83411b9e99c
@@ -309,6 +309,8 @@
); );
inputPaths = ( inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Starscream-framework/Starscream.framework",
"${BUILT_PRODUCTS_DIR}/StreamChatClient-framework/StreamChatClient.framework",
"${BUILT_PRODUCTS_DIR}/DKImagePickerController/DKImagePickerController.framework", "${BUILT_PRODUCTS_DIR}/DKImagePickerController/DKImagePickerController.framework",
"${BUILT_PRODUCTS_DIR}/DKPhotoGallery/DKPhotoGallery.framework", "${BUILT_PRODUCTS_DIR}/DKPhotoGallery/DKPhotoGallery.framework",
"${BUILT_PRODUCTS_DIR}/FMDB/FMDB.framework", "${BUILT_PRODUCTS_DIR}/FMDB/FMDB.framework",
@@ -336,6 +338,8 @@
); );
name = "[CP] Embed Pods Frameworks"; name = "[CP] Embed Pods Frameworks";
outputPaths = ( outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Starscream.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/StreamChatClient.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DKImagePickerController.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DKImagePickerController.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DKPhotoGallery.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DKPhotoGallery.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FMDB.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FMDB.framework",
+80 -23
View File
@@ -29,7 +29,14 @@ void main() async {
runApp(MyApp()); runApp(MyApp());
} }
class MyApp extends StatelessWidget { class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
InitData _initData;
Future<InitData> _initConnection() async { Future<InitData> _initConnection() async {
final secureStorage = FlutterSecureStorage(); final secureStorage = FlutterSecureStorage();
@@ -55,41 +62,46 @@ class MyApp extends StatelessWidget {
} }
@override @override
Widget build(BuildContext context) { void initState() {
return FutureBuilder<InitData>( _initConnection().then(
future: _initConnection(), (initData) {
builder: (context, initData) { setState(() {
if (!initData.hasData) { _initData = initData;
return MaterialApp( });
home: Container( },
alignment: Alignment.center, );
color: Colors.white, super.initState();
child: Container( }
Widget _buildAnimation() {
return Container(
alignment: Alignment.center, alignment: Alignment.center,
constraints: BoxConstraints.expand(), constraints: BoxConstraints.expand(),
color: Color(0xff005FFF), color: Color(0xff005FFF),
child: Lottie.asset( child: Lottie.asset(
'assets/floating_boat.json', 'assets/floating_boat.json',
width: 100, alignment: Alignment.center,
height: 100,
fit: BoxFit.fill,
),
),
), ),
); );
} }
@override
Widget build(BuildContext context) {
if (_initData == null) {
return _buildAnimation();
}
return PreferenceBuilder<int>( return PreferenceBuilder<int>(
preference: initData.data.preferences.getInt( preference: _initData.preferences.getInt(
'theme', 'theme',
defaultValue: 0, defaultValue: 0,
), ),
builder: (context, snapshot) => MaterialApp( builder: (context, snapshot) => MaterialApp(
builder: (context, child) { builder: (context, child) {
return StreamChat( return StreamChat(
client: initData.data.client, client: _initData.client,
onBackgroundEventReceived: (e) => showLocalNotification( onBackgroundEventReceived: (e) =>
e, initData.data.client.state.user.id), showLocalNotification(e, _initData.client.state.user.id),
child: Builder( child: Builder(
builder: (context) => AnnotatedRegion<SystemUiOverlayStyle>( builder: (context) => AnnotatedRegion<SystemUiOverlayStyle>(
child: child, child: child,
@@ -113,13 +125,11 @@ class MyApp extends StatelessWidget {
1: ThemeMode.light, 1: ThemeMode.light,
}[snapshot], }[snapshot],
onGenerateRoute: AppRoutes.generateRoute, onGenerateRoute: AppRoutes.generateRoute,
initialRoute: initData.data.client.state.user == null initialRoute: _initData.client.state.user == null
? Routes.CHOOSE_USER ? Routes.CHOOSE_USER
: Routes.HOME, : Routes.HOME,
), ),
); );
},
);
} }
} }
@@ -861,3 +871,50 @@ class InitData {
InitData(this.client, this.preferences); InitData(this.client, this.preferences);
} }
class HolePainter extends CustomPainter {
HolePainter({
@required this.color,
@required this.holeSize,
});
Color color;
double holeSize;
@override
void paint(Canvas canvas, Size size) {
double radius = holeSize / 2;
Rect rect = Rect.fromLTWH(0, 0, size.width, size.height);
Rect outerCircleRect = Rect.fromCircle(
center: Offset(size.width / 2, size.height / 2), radius: radius);
Rect innerCircleRect = Rect.fromCircle(
center: Offset(size.width / 2, size.height / 2), radius: radius / 2);
Path transparentHole = Path.combine(
PathOperation.difference,
Path()..addRect(rect),
Path()
..addOval(outerCircleRect)
..close(),
);
Path halfTransparentRing = Path.combine(
PathOperation.difference,
Path()
..addOval(outerCircleRect)
..close(),
Path()
..addOval(innerCircleRect)
..close(),
);
canvas.drawPath(transparentHole, Paint()..color = color);
canvas.drawPath(
halfTransparentRing, Paint()..color = color.withOpacity(0.5));
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}