Skip to content

Commit 60a380a

Browse files
committed
migrate about screen to cmp
1 parent 1e9da63 commit 60a380a

File tree

14 files changed

+299
-179
lines changed

14 files changed

+299
-179
lines changed

app/src/main/java/dev/dimension/flare/ui/component/status/CommonStatusComponent.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -964,14 +964,14 @@ private fun ExpandedCard(
964964
val appearanceSettings = LocalAppearanceSettings.current
965965
Column(
966966
modifier =
967-
modifier
967+
Modifier
968968
.border(
969969
FlareDividerDefaults.thickness,
970970
color = FlareDividerDefaults.color,
971971
shape = MaterialTheme.shapes.medium,
972972
).clip(
973973
shape = MaterialTheme.shapes.medium,
974-
),
974+
).then(modifier),
975975
) {
976976
card.media?.let {
977977
AdaptiveGrid(
@@ -1016,14 +1016,14 @@ fun CompatCard(
10161016
) {
10171017
Row(
10181018
modifier =
1019-
modifier
1019+
Modifier
10201020
.border(
10211021
FlareDividerDefaults.thickness,
10221022
color = FlareDividerDefaults.color,
10231023
shape = MaterialTheme.shapes.medium,
10241024
).clip(
10251025
shape = MaterialTheme.shapes.medium,
1026-
),
1026+
).then(modifier),
10271027
) {
10281028
card.media?.let {
10291029
MediaItem(
Lines changed: 4 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,19 @@
11
package dev.dimension.flare.ui.screen.settings
22

3-
import androidx.compose.foundation.Image
4-
import androidx.compose.foundation.clickable
5-
import androidx.compose.foundation.layout.Column
63
import androidx.compose.foundation.layout.padding
7-
import androidx.compose.foundation.layout.size
8-
import androidx.compose.foundation.rememberScrollState
9-
import androidx.compose.foundation.verticalScroll
104
import androidx.compose.material3.ExperimentalMaterial3Api
11-
import androidx.compose.material3.ListItem
12-
import androidx.compose.material3.MaterialTheme
135
import androidx.compose.material3.Text
146
import androidx.compose.material3.TopAppBar
157
import androidx.compose.runtime.Composable
16-
import androidx.compose.ui.Alignment
178
import androidx.compose.ui.Modifier
18-
import androidx.compose.ui.draw.alpha
19-
import androidx.compose.ui.platform.LocalUriHandler
20-
import androidx.compose.ui.res.painterResource
219
import androidx.compose.ui.res.stringResource
22-
import androidx.compose.ui.text.style.TextAlign
23-
import androidx.compose.ui.unit.dp
2410
import com.ramcosta.composedestinations.annotation.Destination
2511
import com.ramcosta.composedestinations.annotation.RootGraph
26-
import compose.icons.FontAwesomeIcons
27-
import compose.icons.fontawesomeicons.Brands
28-
import compose.icons.fontawesomeicons.Solid
29-
import compose.icons.fontawesomeicons.brands.Github
30-
import compose.icons.fontawesomeicons.brands.Telegram
31-
import compose.icons.fontawesomeicons.solid.Language
3212
import dev.dimension.flare.BuildConfig
3313
import dev.dimension.flare.R
3414
import dev.dimension.flare.ui.component.BackButton
35-
import dev.dimension.flare.ui.component.FAIcon
3615
import dev.dimension.flare.ui.component.FlareScaffold
3716
import dev.dimension.flare.ui.component.ThemeWrapper
38-
import dev.dimension.flare.ui.theme.MediumAlpha
3917

4018
@Destination<RootGraph>(
4119
wrappers = [ThemeWrapper::class],
@@ -50,7 +28,6 @@ internal fun AboutRoute(navigator: ProxyDestinationsNavigator) {
5028
@OptIn(ExperimentalMaterial3Api::class)
5129
@Composable
5230
private fun AboutScreen(onBack: () -> Unit) {
53-
val uriHandler = LocalUriHandler.current
5431
FlareScaffold(
5532
topBar = {
5633
TopAppBar(
@@ -63,101 +40,11 @@ private fun AboutScreen(onBack: () -> Unit) {
6340
)
6441
},
6542
) {
66-
Column(
43+
AboutScreenContent(
44+
version = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})",
6745
modifier =
6846
Modifier
69-
.padding(it)
70-
.verticalScroll(rememberScrollState()),
71-
horizontalAlignment = Alignment.CenterHorizontally,
72-
) {
73-
Image(
74-
painter = painterResource(R.drawable.ic_launcher_foreground),
75-
contentDescription = stringResource(id = R.string.app_name),
76-
)
77-
Text(
78-
text = stringResource(id = R.string.app_name),
79-
style = MaterialTheme.typography.headlineMedium,
80-
)
81-
Text(
82-
text = stringResource(id = R.string.settings_about_description),
83-
textAlign = TextAlign.Center,
84-
style = MaterialTheme.typography.bodySmall,
85-
modifier =
86-
Modifier
87-
.alpha(MediumAlpha)
88-
.padding(horizontal = 16.dp),
89-
)
90-
Text(
91-
text = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})",
92-
style = MaterialTheme.typography.bodySmall,
93-
modifier = Modifier.alpha(MediumAlpha),
94-
)
95-
ListItem(
96-
headlineContent = {
97-
Text(text = stringResource(id = R.string.settings_about_source_code))
98-
},
99-
supportingContent = {
100-
Text(
101-
text = "https://github.com/DimensionDev/Flare",
102-
modifier = Modifier.alpha(MediumAlpha),
103-
)
104-
},
105-
modifier =
106-
Modifier.clickable {
107-
uriHandler.openUri("https://github.com/DimensionDev/Flare")
108-
},
109-
leadingContent = {
110-
FAIcon(
111-
imageVector = FontAwesomeIcons.Brands.Github,
112-
contentDescription = "GitHub",
113-
modifier = Modifier.size(24.dp),
114-
)
115-
},
116-
)
117-
ListItem(
118-
headlineContent = {
119-
Text(text = stringResource(id = R.string.settings_about_telegram))
120-
},
121-
supportingContent = {
122-
Text(
123-
text = stringResource(id = R.string.settings_about_telegram_description),
124-
modifier = Modifier.alpha(MediumAlpha),
125-
)
126-
},
127-
modifier =
128-
Modifier.clickable {
129-
uriHandler.openUri("https://t.me/+0UtcP6_qcDoyOWE1")
130-
},
131-
leadingContent = {
132-
FAIcon(
133-
imageVector = FontAwesomeIcons.Brands.Telegram,
134-
contentDescription = stringResource(id = R.string.settings_about_telegram),
135-
modifier = Modifier.size(24.dp),
136-
)
137-
},
138-
)
139-
ListItem(
140-
headlineContent = {
141-
Text(text = stringResource(id = R.string.settings_about_localization))
142-
},
143-
supportingContent = {
144-
Text(
145-
text = stringResource(id = R.string.settings_about_localization_description),
146-
modifier = Modifier.alpha(MediumAlpha),
147-
)
148-
},
149-
modifier =
150-
Modifier.clickable {
151-
uriHandler.openUri("https://crowdin.com/project/flareapp")
152-
},
153-
leadingContent = {
154-
FAIcon(
155-
imageVector = FontAwesomeIcons.Solid.Language,
156-
contentDescription = stringResource(id = R.string.settings_about_localization),
157-
modifier = Modifier.size(24.dp),
158-
)
159-
},
160-
)
161-
}
47+
.padding(it),
48+
)
16249
}
16350
}

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ material-motion-compose = { module = "io.github.fornewid:material-motion-compose
169169

170170
precompose-molecule = { module = "moe.tlaster:precompose-molecule", version = "1.7.0-alpha03" }
171171

172+
compose-cupertino = { module = "io.github.alexzhirkevich:cupertino-core", version = "0.1.0-alpha04" }
173+
172174
[bundles]
173175
compose = ["ui", "ui-util", "ui-graphics", "ui-tooling", "ui-tooling-preview", "material3", "material3WindowSizeClass", "material3-adaptive-navigation-suite", "material3-adaptive", "material3-adaptive-navigation", "material3-adaptive-layout"]
174176
navigation = ["navigation-compose"]

iosApp/iosApp.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/* Begin PBXBuildFile section */
1010
058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; };
1111
058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; };
12+
06005F5A2CEC976F0060A785 /* ComposeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06005F592CEC97660060A785 /* ComposeView.swift */; };
1213
060501BC2ACA985B00DBCCEB /* StatusTimelineBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 060501BB2ACA985B00DBCCEB /* StatusTimelineBuilder.swift */; };
1314
060501BE2ACAC4ED00DBCCEB /* NotificationScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 060501BD2ACAC4ED00DBCCEB /* NotificationScreen.swift */; };
1415
060501C02ACAC8AF00DBCCEB /* SplashScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 060501BF2ACAC8AF00DBCCEB /* SplashScreen.swift */; };
@@ -78,6 +79,7 @@
7879
/* Begin PBXFileReference section */
7980
058557BA273AAA24004C7B11 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
8081
058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
82+
06005F592CEC97660060A785 /* ComposeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeView.swift; sourceTree = "<group>"; };
8183
060501BB2ACA985B00DBCCEB /* StatusTimelineBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusTimelineBuilder.swift; sourceTree = "<group>"; };
8284
060501BD2ACAC4ED00DBCCEB /* NotificationScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationScreen.swift; sourceTree = "<group>"; };
8385
060501BF2ACAC8AF00DBCCEB /* SplashScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashScreen.swift; sourceTree = "<group>"; };
@@ -239,6 +241,7 @@
239241
066151222AC54A8200CCB945 /* Component */ = {
240242
isa = PBXGroup;
241243
children = (
244+
06005F592CEC97660060A785 /* ComposeView.swift */,
242245
069050772CAE6100007FC957 /* SwitUIInAppNotification.swift */,
243246
06C862742B4D2A46008C902C /* Compact */,
244247
060501C42ACBF40700DBCCEB /* User */,
@@ -577,6 +580,7 @@
577580
062A3C892C6C9ECD00A45E44 /* VVOLoginScreen.swift in Sources */,
578581
060881C12AE10D35001AAD2F /* ComposeViewModel.swift in Sources */,
579582
0620DD9E2AC44237009BD1BE /* HomeTimelineScreen.swift in Sources */,
583+
06005F5A2CEC976F0060A785 /* ComposeView.swift in Sources */,
580584
061C2CFC2B4E77D700249514 /* FullScreenImageViewer.swift in Sources */,
581585
061C2CFE2B4E82C900249514 /* ImageViewWindow.swift in Sources */,
582586
06F4B4C92C6369390005317F /* VGrid.swift in Sources */,

iosApp/iosApp.xcodeproj/xcuserdata/tlaster.xcuserdatad/xcschemes/xcschememanagement.plist

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,27 @@
99
<key>isShown</key>
1010
<false />
1111
<key>orderHint</key>
12-
<integer>3</integer>
12+
<integer>2</integer>
1313
</dict>
1414
<key>Promises (Playground) 2.xcscheme</key>
1515
<dict>
1616
<key>isShown</key>
1717
<false />
1818
<key>orderHint</key>
19-
<integer>4</integer>
19+
<integer>3</integer>
2020
</dict>
2121
<key>Promises (Playground).xcscheme</key>
2222
<dict>
2323
<key>isShown</key>
2424
<false />
2525
<key>orderHint</key>
26-
<integer>2</integer>
26+
<integer>1</integer>
2727
</dict>
2828
<key>iosApp.xcscheme</key>
2929
<dict>
3030
<key>orderHint</key>
3131
<integer>0</integer>
3232
</dict>
33-
<key>iosApp.xcscheme_^#shared#^_</key>
34-
<dict>
35-
<key>orderHint</key>
36-
<integer>1</integer>
37-
</dict>
3833
</dict>
3934
</dict>
4035
</plist>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import shared
2+
import SwiftUI
3+
4+
struct ComposeView: UIViewControllerRepresentable {
5+
let controller: UIViewController
6+
func makeUIViewController(context: Context) -> UIViewController {
7+
return controller
8+
}
9+
10+
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
11+
}
12+
}
Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,19 @@
11
import SwiftUI
2+
import shared
23

34
struct AboutScreen: View {
5+
@Environment(\.colorScheme) var colorScheme
6+
@Environment(\.openURL) var openURL
47
var body: some View {
58
let versionName = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""
69
let versionCode = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? ""
7-
ScrollView {
8-
VStack {
9-
Image(.logo)
10-
.resizable()
11-
.frame(width: 96, height: 96)
12-
.clipShape(RoundedRectangle(cornerRadius: 16))
13-
.clipped()
14-
.padding()
15-
Text("Flare")
16-
.font(.title)
17-
Text("about_description")
18-
.multilineTextAlignment(.center)
19-
HStack {
20-
Text(versionName)
21-
Text("("+versionCode+")")
22-
}
23-
.opacity(0.5)
24-
.font(.caption)
25-
Link(
26-
destination: URL(string: "https://github.com/DimensionDev/Flare")!
27-
) {
28-
HStack {
29-
AsyncImage(
30-
url: URL(string: "https://github.githubassets.com/assets/GitHub-Mark-ea2971cee799.png")
31-
) { image in
32-
image.image?.resizable()
33-
}
34-
.frame(width: 48, height: 48)
35-
VStack(alignment: .leading) {
36-
Text("about_source_code")
37-
Text("https://github.com/DimensionDev/Flare")
38-
}
39-
Spacer()
40-
}
41-
}
42-
.buttonStyle(.plain)
43-
}
44-
.padding()
45-
}
10+
ComposeView(
11+
controller: AboutViewController(
12+
version: "\(versionName) (\(versionCode))",
13+
onOpenLink: { openURL(.init(string: $0)!) },
14+
darkMode: colorScheme == .dark
15+
)
16+
)
4617
.navigationTitle("about_title")
4718
}
4819
}
49-
50-
#Preview {
51-
NavigationStack {
52-
AboutScreen()
53-
}
54-
}

shared/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ kotlin {
103103
dependencies {
104104
implementation(libs.ktor.client.darwin)
105105
implementation(libs.lifecycle.viewmodel.compose)
106+
implementation(libs.compose.cupertino)
106107
}
107108
}
108109
val nativeMain by getting {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="108dp"
3+
android:height="108dp"
4+
android:viewportWidth="1024"
5+
android:viewportHeight="1024">
6+
<group android:scaleX="0.66"
7+
android:scaleY="0.66"
8+
android:translateX="174.08"
9+
android:translateY="174.08">
10+
<path
11+
android:pathData="M529.8,822.9C425.9,828.1 329.2,767.1 293.2,670.6C285.5,650.1 280.4,628.3 279.3,605.4C272.9,477.5 373.6,368.9 373.6,368.9C373.6,368.9 368.4,411.1 374.7,446.4C381,481.8 398.8,502.8 398.8,502.8C398.8,502.8 383.8,447.5 398.2,409.3C414.7,365.2 448.5,343.5 459.9,304C473.1,258.6 447.4,207.8 447.4,207.8C447.4,207.8 524.8,233 583.4,305.1C649.8,387 613.4,498.5 613.4,498.5C613.4,498.5 617.7,468 647.9,441.9C678.1,415.8 663.4,378.5 663.4,378.5C663.4,378.5 753.1,468.5 758.8,581.4C760.3,612.1 753,643.5 741.5,672.9C707.5,759.9 623.9,818.2 529.8,822.9Z"
12+
android:fillColor="#DD5D00"/>
13+
<path
14+
android:pathData="M528,780.9C446.5,785 370.7,737.2 342.5,661.6C336.5,645.6 332.5,628.4 331.6,610.5C326.6,510.3 340.2,448.7 340.2,448.7C340.2,448.7 374.5,473.5 379.5,501.2C384.4,528.9 404.8,541.2 404.8,541.2C404.8,541.2 401.7,478.6 430,444.2C452.1,417.3 484.9,408.4 482.5,359C480.4,318.1 498.1,272.4 498.1,272.4C498.1,272.4 555.7,325.6 578,369.1C610.8,433.1 605.5,550.9 605.5,550.9C605.5,550.9 603.6,540.4 627.3,520C651,499.6 660.5,450.8 660.5,450.8C660.5,450.8 703.2,503.2 707.6,591.7C708.8,615.7 703,640.3 694,663.4C667.4,731.6 601.8,777.2 528,780.9Z"
15+
android:fillColor="#FF7A00"/>
16+
<path
17+
android:pathData="M405,644.2C402.1,586.9 438.1,548.1 460.4,523.2C500.2,478.9 490.4,431.2 490.4,431.2C490.4,431.2 576.1,497.3 591.9,554.9C607,610 577.5,642.5 577.5,642.5C577.5,642.5 591.7,636.2 600.2,625.8C611,612.6 614.4,597 614.4,597C614.4,597 619.7,608.3 615.4,648C612.4,676.3 598.8,698 582.4,714.2C542.5,753.8 477.2,753.4 437.3,713.9C420.2,697 406.5,674.2 405,644.2Z"
18+
android:fillColor="#FFB800"/>
19+
<path
20+
android:pathData="M400.6,194.8C400.6,194.8 433.7,213.2 434.9,250.4C435.6,270.1 426.3,286.4 419.7,304.3C413.9,320.2 413.7,344.1 413.7,344.1C413.7,344.1 390.8,326.5 386.4,285.2C384.6,268.9 392.4,248.8 396.2,234.5C402.1,212.3 400.6,194.8 400.6,194.8V194.8Z"
21+
android:fillColor="#DD5D00"/>
22+
<path
23+
android:pathData="M544.4,223.9C544.4,223.9 556.1,202.5 544,181.8C537.7,170.9 527.1,165.2 517.4,157.8C508.8,151.1 500.6,138.2 500.6,138.2C500.6,138.2 494.2,155.6 505.9,179.6C510.5,189 521.6,197.3 528.5,203.8C539.3,213.8 544.4,223.9 544.4,223.9V223.9Z"
24+
android:fillColor="#DD5D00"/>
25+
<path
26+
android:pathData="M642.8,363.2C642.8,363.2 668.6,335.5 658.3,299.6C652.8,280.6 632.1,269.1 618.2,255.9C604,242.5 596.5,217.4 596.5,217.4C596.5,217.4 583,235.5 593.8,268.7C600.7,290 619.6,304.8 627.7,317.3C640.3,336.6 642.8,363.2 642.8,363.2V363.2Z"
27+
android:fillColor="#DD5D00"/>
28+
</group>
29+
</vector>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
<resources>
22
<string name="app_name" translatable="false">Flare</string>
3+
4+
<string name="settings_about_description">The ultimate next generation open-sourced AI powered decentralized social network client.</string>
5+
<string name="settings_about_source_code">Source code</string>
6+
<string name="settings_about_telegram">Telegram</string>
7+
<string name="settings_about_telegram_description">Join our Telegram group</string>
8+
<string name="settings_about_localization">Crowdin</string>
9+
<string name="settings_about_localization_description">Help us translate Flare</string>
310
</resources>

0 commit comments

Comments
 (0)