samre-cli 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/templates/flutter_sdk.js +30 -28
- package/src/utils/flutter.js +25 -7
package/package.json
CHANGED
|
@@ -79,38 +79,40 @@ class _SamreOverlayState extends State<SamreOverlay> {
|
|
|
79
79
|
children: [
|
|
80
80
|
widget.child,
|
|
81
81
|
|
|
82
|
-
// ── Bouton Flottant
|
|
82
|
+
// ── Bouton Flottant Rehaussé avec SafeArea (Au-dessus des barres de navigation) ──
|
|
83
83
|
Positioned(
|
|
84
|
-
bottom:
|
|
85
|
-
right:
|
|
86
|
-
child:
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
color: _canSubmit ? const Color(0xFF2563EB) : Colors.black.withOpacity(0.75),
|
|
90
|
-
child: InkWell(
|
|
84
|
+
bottom: 48,
|
|
85
|
+
right: 18,
|
|
86
|
+
child: SafeArea(
|
|
87
|
+
child: Material(
|
|
88
|
+
elevation: 10,
|
|
91
89
|
borderRadius: BorderRadius.circular(24),
|
|
92
|
-
|
|
93
|
-
child:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const SizedBox(width: 8),
|
|
104
|
-
Text(
|
|
105
|
-
_canSubmit ? 'Valider Journée' : 'Test en cours (\${_secondsRemaining}s)',
|
|
106
|
-
style: const TextStyle(
|
|
90
|
+
color: _canSubmit ? const Color(0xFF2563EB) : Colors.black.withOpacity(0.85),
|
|
91
|
+
child: InkWell(
|
|
92
|
+
borderRadius: BorderRadius.circular(24),
|
|
93
|
+
onTap: _canSubmit ? _openDialog : null,
|
|
94
|
+
child: Padding(
|
|
95
|
+
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
|
96
|
+
child: Row(
|
|
97
|
+
mainAxisSize: MainAxisSize.min,
|
|
98
|
+
children: [
|
|
99
|
+
Icon(
|
|
100
|
+
_canSubmit ? Icons.verified_user : Icons.timer_outlined,
|
|
107
101
|
color: Colors.white,
|
|
108
|
-
|
|
109
|
-
fontSize: 12,
|
|
110
|
-
decoration: TextDecoration.none,
|
|
102
|
+
size: 18,
|
|
111
103
|
),
|
|
112
|
-
|
|
113
|
-
|
|
104
|
+
const SizedBox(width: 8),
|
|
105
|
+
Text(
|
|
106
|
+
_canSubmit ? 'Valider Journée' : 'Test en cours (\${_secondsRemaining}s)',
|
|
107
|
+
style: const TextStyle(
|
|
108
|
+
color: Colors.white,
|
|
109
|
+
fontWeight: FontWeight.bold,
|
|
110
|
+
fontSize: 12,
|
|
111
|
+
decoration: TextDecoration.none,
|
|
112
|
+
),
|
|
113
|
+
),
|
|
114
|
+
],
|
|
115
|
+
),
|
|
114
116
|
),
|
|
115
117
|
),
|
|
116
118
|
),
|
package/src/utils/flutter.js
CHANGED
|
@@ -76,14 +76,33 @@ export const FlutterUtil = {
|
|
|
76
76
|
|
|
77
77
|
let modified = content;
|
|
78
78
|
|
|
79
|
-
// 1. Ajouter l'import en haut
|
|
80
|
-
const importStatement = "import 'package:flutter/material.dart';\nimport 'samre_sdk.dart';\n";
|
|
79
|
+
// 1. Ajouter l'import de samre_sdk en haut (sans dupliquer material.dart)
|
|
81
80
|
if (!modified.includes('samre_sdk.dart')) {
|
|
82
|
-
modified =
|
|
81
|
+
modified = "import 'samre_sdk.dart';\n" + modified;
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
// 2. Tenter d'
|
|
86
|
-
|
|
84
|
+
// 2. Tenter d'injecter dans builder de MaterialApp (Idéal pour tous les écrans et le routage)
|
|
85
|
+
if (modified.includes('MaterialApp(') && !modified.includes('SamreOverlay')) {
|
|
86
|
+
// Si MaterialApp a déjà une propriété builder
|
|
87
|
+
const builderRegex = /builder\s*:\s*\(([^)]*)\)\s*=>\s*([^,\n;]+)/;
|
|
88
|
+
if (builderRegex.test(modified)) {
|
|
89
|
+
modified = modified.replace(builderRegex, (match, args, body) => {
|
|
90
|
+
return `builder: (${args}) => SamreOverlay(child: ${body.trim()})`;
|
|
91
|
+
});
|
|
92
|
+
fs.writeFileSync(mainPath, modified, 'utf-8');
|
|
93
|
+
return { injected: true, modifiedBuilder: true, backupPath };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Sinon insérer la propriété builder juste après MaterialApp(
|
|
97
|
+
modified = modified.replace(
|
|
98
|
+
/MaterialApp\s*\(/,
|
|
99
|
+
'MaterialApp(\n builder: (context, child) => SamreOverlay(child: child ?? const SizedBox()),'
|
|
100
|
+
);
|
|
101
|
+
fs.writeFileSync(mainPath, modified, 'utf-8');
|
|
102
|
+
return { injected: true, modifiedBuilder: true, backupPath };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Fallback : injection sur home:
|
|
87
106
|
const homeRegex = /home\s*:\s*([^,\n\);]+)/;
|
|
88
107
|
if (homeRegex.test(modified) && !modified.includes('SamreOverlay')) {
|
|
89
108
|
modified = modified.replace(homeRegex, (match, p1) => {
|
|
@@ -93,8 +112,6 @@ export const FlutterUtil = {
|
|
|
93
112
|
return { injected: true, modifiedHome: true, backupPath };
|
|
94
113
|
}
|
|
95
114
|
|
|
96
|
-
// Si injection automatique du widget home n'a pas pu matcher le pattern exact,
|
|
97
|
-
// on sauvegarde le fichier avec l'import et on informe le dev
|
|
98
115
|
fs.writeFileSync(mainPath, modified, 'utf-8');
|
|
99
116
|
return { injected: false, importAdded: true, backupPath };
|
|
100
117
|
},
|
|
@@ -121,6 +138,7 @@ export const FlutterUtil = {
|
|
|
121
138
|
// Nettoyage manuel si pas de backup
|
|
122
139
|
let content = fs.readFileSync(mainPath, 'utf-8');
|
|
123
140
|
content = content.replace(/import\s+['"]samre_sdk\.dart['"];\s*\n?/g, '');
|
|
141
|
+
content = content.replace(/builder\s*:\s*\([^)]*\)\s*=>\s*SamreOverlay\s*\(\s*child\s*:\s*child\s*\?\?\s*const\s*SizedBox\(\)\s*\),?\s*\n?/g, '');
|
|
124
142
|
content = content.replace(/SamreOverlay\s*\(\s*child\s*:\s*([^)]+)\)/g, '$1');
|
|
125
143
|
fs.writeFileSync(mainPath, content, 'utf-8');
|
|
126
144
|
mainRestored = true;
|