Skip to content

Commit 148a0b7

Browse files
committed
live icon data
1 parent 4ce536d commit 148a0b7

13 files changed

+179
-41
lines changed

android/.classpath

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-15/"/>
4+
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
5+
<classpathentry kind="output" path="bin/default"/>
6+
</classpath>

android/.project

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>live_icon</name>
4+
<comment>Project android created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
22+
</natures>
23+
<filteredResources>
24+
<filter>
25+
<id>1621942381800</id>
26+
<name></name>
27+
<type>30</type>
28+
<matcher>
29+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
30+
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31+
</matcher>
32+
</filter>
33+
</filteredResources>
34+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
arguments=
2+
auto.sync=false
3+
build.scans.enabled=false
4+
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(6.8))
5+
connection.project.dir=../example/android
6+
eclipse.preferences.version=1
7+
gradle.user.home=
8+
java.home=C\:/Program Files/AdoptOpenJDK/jdk-15.0.2.7-hotspot
9+
jvm.arguments=
10+
offline.mode=false
11+
override.workspace.settings=true
12+
show.console.view=true
13+
show.executions.view=true

example/android/.project

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>android</name>
4+
<comment>Project android created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16+
</natures>
17+
<filteredResources>
18+
<filter>
19+
<id>1621942381766</id>
20+
<name></name>
21+
<type>30</type>
22+
<matcher>
23+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
24+
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
25+
</matcher>
26+
</filter>
27+
</filteredResources>
28+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
arguments=
2+
auto.sync=false
3+
build.scans.enabled=false
4+
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(6.8))
5+
connection.project.dir=
6+
eclipse.preferences.version=1
7+
gradle.user.home=
8+
java.home=C\:/Program Files/AdoptOpenJDK/jdk-15.0.2.7-hotspot
9+
jvm.arguments=
10+
offline.mode=false
11+
override.workspace.settings=true
12+
show.console.view=true
13+
show.executions.view=true

example/android/app/.classpath

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-15/"/>
4+
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
5+
<classpathentry kind="output" path="bin/default"/>
6+
</classpath>

example/android/app/.project

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>app</name>
4+
<comment>Project app created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
22+
</natures>
23+
<filteredResources>
24+
<filter>
25+
<id>1621942381783</id>
26+
<name></name>
27+
<type>30</type>
28+
<matcher>
29+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
30+
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31+
</matcher>
32+
</filter>
33+
</filteredResources>
34+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
connection.project.dir=..
2+
eclipse.preferences.version=1

example/lib/main.dart

+12-25
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import 'package:flutter/material.dart';
2-
import 'dart:async';
32

4-
import 'package:flutter/services.dart';
53
import 'package:live_icon/live_icon.dart';
64

75
void main() {
@@ -14,32 +12,21 @@ class MyApp extends StatefulWidget {
1412
}
1513

1614
class _MyAppState extends State<MyApp> {
17-
String _platformVersion = 'Unknown';
15+
LiveIcon liveIcon = LiveIcon();
1816

1917
@override
2018
void initState() {
2119
super.initState();
22-
initPlatformState();
23-
}
24-
25-
// Platform messages are asynchronous, so we initialize in an async method.
26-
Future<void> initPlatformState() async {
27-
String platformVersion;
28-
// Platform messages may fail, so we use a try/catch PlatformException.
29-
try {
30-
platformVersion = await LiveIcon.platformVersion;
31-
} on PlatformException {
32-
platformVersion = 'Failed to get platform version.';
33-
}
34-
35-
// If the widget was removed from the tree while the asynchronous platform
36-
// message was in flight, we want to discard the reply rather than calling
37-
// setState to update our non-existent appearance.
38-
if (!mounted) return;
39-
40-
setState(() {
41-
_platformVersion = platformVersion;
42-
});
20+
liveIcon.initialize(icons: [
21+
const LiveIconData(
22+
iconName: "darkTheme",
23+
className: "DarkTheme",
24+
),
25+
const LiveIconData(
26+
iconName: "lightTheme",
27+
className: "LightTheme",
28+
),
29+
]);
4330
}
4431

4532
@override
@@ -50,7 +37,7 @@ class _MyAppState extends State<MyApp> {
5037
title: const Text('Plugin example app'),
5138
),
5239
body: Center(
53-
child: Text('Running on: $_platformVersion\n'),
40+
child: Text(''),
5441
),
5542
),
5643
);

lib/live_icon.dart

+20-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
1-
21
import 'dart:async';
32

43
import 'package:flutter/services.dart';
4+
import './src/helper/helper.dart';
5+
6+
export './src/helper/helper.dart';
57

68
class LiveIcon {
7-
static const MethodChannel _channel =
8-
const MethodChannel('live_icon');
9+
static const MethodChannel _channel = const MethodChannel('live_icon');
10+
11+
Future<void> initialize({List<LiveIconData> icons}) async {
12+
List<Map<String, String>> iconData = _serializeLiveIconData(icons);
13+
await _channel.invokeMethod("initialize", iconData);
14+
}
915

10-
static Future<String> get platformVersion async {
11-
final String version = await _channel.invokeMethod('getPlatformVersion');
12-
return version;
16+
List<Map<String, String>> _serializeLiveIconData(List<LiveIconData> icons) {
17+
List<Map<String, String>> iconData;
18+
for (LiveIconData icon in icons) {
19+
iconData.add(
20+
<String, String>{
21+
'iconName': icon.iconName,
22+
'className': icon.className,
23+
},
24+
);
25+
}
26+
return iconData;
1327
}
1428
}

lib/src/helper/helper.dart

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export 'model/live_icon_data.dart';
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class LiveIconData {
2+
const LiveIconData({
3+
this.iconName,
4+
this.className,
5+
});
6+
7+
final String iconName;
8+
final String className;
9+
}

test/live_icon_test.dart

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
11
import 'package:flutter/services.dart';
22
import 'package:flutter_test/flutter_test.dart';
3-
import 'package:live_icon/live_icon.dart';
43

54
void main() {
65
const MethodChannel channel = MethodChannel('live_icon');
76

87
TestWidgetsFlutterBinding.ensureInitialized();
98

10-
setUp(() {
11-
channel.setMockMethodCallHandler((MethodCall methodCall) async {
12-
return '42';
13-
});
14-
});
9+
setUp(() {});
1510

1611
tearDown(() {
1712
channel.setMockMethodCallHandler(null);
1813
});
19-
20-
test('getPlatformVersion', () async {
21-
expect(await LiveIcon.platformVersion, '42');
22-
});
2314
}

0 commit comments

Comments
 (0)