malliaridis commented on code in PR #2605:
URL: https://github.com/apache/solr/pull/2605#discussion_r1709602921


##########
solr/compose-ui/src/commonMain/kotlin/org/apache/solr/composeui/ui/icons/SolrLogo.kt:
##########
@@ -0,0 +1,257 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.composeui.ui.icons
+
+import androidx.compose.foundation.layout.Box
+import androidx.compose.material.icons.materialPath
+import androidx.compose.material3.Icon
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.vector.ImageVector
+import androidx.compose.ui.graphics.vector.rememberVectorPainter
+import androidx.compose.ui.unit.dp
+import org.apache.solr.compose_ui.generated.resources.Res
+import org.apache.solr.compose_ui.generated.resources.cd_solr_logo
+import org.jetbrains.compose.resources.stringResource
+
+/**
+ * Colorized Solr logo.
+ *
+ * @param modifier Modifier that is applied to the wrapper of the logo.
+ */
+@Composable
+fun SolrLogo(
+    modifier: Modifier = Modifier,
+) {
+    val solrPainter = rememberVectorPainter(
+        ImageVector.Builder(
+            name = "Logos.SolrLogo",
+            defaultWidth = 128.dp,
+            defaultHeight = 64.dp,
+            viewportWidth = 128f,
+            viewportHeight = 64f,
+            autoMirror = false,
+        ).apply {
+            materialPath {
+                moveTo(25.7013f, 44.178f)

Review Comment:
   I agree and this is not common practice in general (should be avoided if 
possible for the reasons you mention).
   
   In compose, users normally import SVGs to convert them to usable resource 
files (a different XML that is common in Android), which still can be rendered 
in IntelliJ and Android Studio and is the common practice and format for 
resource files that are image vectors. [Compose natively supports that 
format](https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-images-resources.html#images)
 and therefore it should be prefered.
   
   However, this format does only support a single tint or predefined colors. 
In the current case, the logo is themed and changes colors based on the theme. 
This is only achievable (afaik) if we have direct access to the groups / 
content of the drawing, which is not the case when we use XML and the Compose 
resources.
   
   And just for reference, Material Icons in Compose are also written and 
distributed in a similar format, but the icons are coming from a library and 
therefore not a developer's problem.
   
   In general, if icons are not available through a library like the _material 
icons_ or _material icons extended_, we would use the import option to import 
an SVG and convert it to a Compose XML, then load it as a resource. This logo 
is only an exception. Providing pre-colored XMLs of the logo for each theme 
would be the alternative approach for loading the logo in the correct colors.
   
   I would provide a dev-guide in the future if this POC gets accepted for how 
to import SVGs and from where to get icons to not have to write such code like 
here.
   
   _P.S. we still can use Compose and IntelliJ to render a preview of the logo 
regardless, so that we have a preview like with the XMLs._



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to