Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.SwipeToDismissBox
import androidx.compose.material3.SwipeToDismissBoxValue
import androidx.compose.material3.Text
Expand All @@ -52,6 +51,8 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import friends.mobile.designkit.DesignTheme
import friends.mobile.designkit.FormTextField
import friends.mobile.designkit.PrimaryButton
import friends.mobile.feature.wishplaces.domain.model.WishPlace

@OptIn(ExperimentalMaterial3Api::class)
Expand Down Expand Up @@ -183,47 +184,49 @@ fun CreateWishPlaceBottomSheet(
onDismissRequest = onDismiss,
sheetState = sheetState,
dragHandle = { BottomSheetDefaults.DragHandle() },
containerColor = Color.White,
scrimColor = Color.Black.copy(alpha = 0.3f)
) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
.padding(DesignTheme.Spacing.lg)
.navigationBarsPadding()
.imePadding()
.verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.spacedBy(12.dp)
verticalArrangement = Arrangement.spacedBy(DesignTheme.Spacing.md)
) {
Text("Add Wish Place", style = MaterialTheme.typography.headlineSmall)
OutlinedTextField(
Text("Add Wish Place", style = DesignTheme.Typography.heading)

FormTextField(
value = title,
onValueChange = { title = it },
label = { Text("Title") },
placeholder = "Title",
modifier = Modifier.fillMaxWidth()
)
OutlinedTextField(
FormTextField(
value = location,
onValueChange = { location = it },
label = { Text("Location") },
placeholder = "Location",
modifier = Modifier.fillMaxWidth()
)
OutlinedTextField(
FormTextField(
value = description,
onValueChange = { description = it },
label = { Text("Description") },
modifier = Modifier.fillMaxWidth(),
minLines = 3
placeholder = "Description",
modifier = Modifier.fillMaxWidth()
)
OutlinedTextField(
FormTextField(
value = link,
onValueChange = { link = it },
label = { Text("Link") },
placeholder = "Link",
modifier = Modifier.fillMaxWidth()
)

Spacer(modifier = Modifier.height(8.dp))
Spacer(modifier = Modifier.height(DesignTheme.Spacing.md))

Button(
PrimaryButton(
text = "Create",
onClick = {
onCreate(
title,
Expand All @@ -232,15 +235,10 @@ fun CreateWishPlaceBottomSheet(
link.ifBlank { null }
)
},
modifier = Modifier
.fillMaxWidth()
.height(50.dp),
enabled = title.isNotBlank()
) {
Text("Create")
}

Spacer(modifier = Modifier.height(32.dp))
isEnabled = title.isNotBlank()
)

Spacer(modifier = Modifier.height(DesignTheme.Spacing.xxxl))
}
}
}
Expand Down
77 changes: 43 additions & 34 deletions iosApp/iosApp/Modules/Profile/WishPlaces/CreateWishPlaceSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,51 @@
import SwiftUI

struct CreateWishPlaceSheet: View {

@State private var title = ""
@State private var description = ""
@State private var location = ""
@State private var link = ""

let onDismiss: () -> Void
let onCreate: (String, String?, String?, String?) -> Void

var isCreateButtonEnabled: Bool {
!title.trimmingCharacters(in: .whitespaces).isEmpty
}

var body: some View {
NavigationStack {
ScrollView {
VStack(spacing: 16) {
VStack(spacing: DesignTheme.Spacing.lg) {
TextField("Title *", text: $title)
.textFieldStyle(.roundedBorder)
.padding(.horizontal)

.placeholder(when: title.isEmpty) {
Text("Title *").foregroundColor(.gray)
}
.formTextField()

TextField("Location", text: $location)
.textFieldStyle(.roundedBorder)
.padding(.horizontal)

.placeholder(when: location.isEmpty) {
Text("Location").foregroundColor(.gray)
}
.formTextField()

TextField("Description", text: $description, axis: .vertical)
.textFieldStyle(.roundedBorder)
.placeholder(when: description.isEmpty) {
Text("Description").foregroundColor(.gray)
}
.formTextField()
.frame(minHeight: 80, maxHeight: 120)
.padding(.horizontal)


TextField("Link", text: $link)
.textFieldStyle(.roundedBorder)
.padding(.horizontal)

.placeholder(when: link.isEmpty) {
Text("Link").foregroundColor(.gray)
}
.formTextField()

Spacer()
.frame(height: 16)

.frame(height: DesignTheme.Spacing.md)
Button(action: {
onCreate(
title,
Expand All @@ -54,36 +62,37 @@ struct CreateWishPlaceSheet: View {
)
}) {
Text("Create")
.frame(maxWidth: .infinity)
.padding(.vertical, 12)
.background(isCreateButtonEnabled ? Color.blue : Color.gray)
.foregroundColor(.white)
.cornerRadius(8)
.font(DesignTheme.Typography.button)
}
.disabled(!isCreateButtonEnabled)
.padding(.horizontal)

.primaryButton(isEnabled: isCreateButtonEnabled)
.padding(.horizontal, DesignTheme.Spacing.lg)
Spacer()
.frame(height: 32)
.frame(height: DesignTheme.Spacing.xxxl)
}
.padding(.vertical, 16)
.padding(.vertical, DesignTheme.Spacing.lg)
.padding(.horizontal, DesignTheme.Spacing.lg)
}
.background(Color(UIColor.systemBackground))
.navigationTitle("Add Wish Place")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
Button("Cancel") {
onDismiss()
}
.foregroundColor(DesignTheme.accentColor)
}
}
}
}
}

#Preview {
CreateWishPlaceSheet(
onDismiss: {},
onCreate: { _, _, _, _ in }
)
extension View {
func placeholder<Content: View>(when shouldShow: Bool, alignment: Alignment = .leading, @ViewBuilder placeholder: () -> Content) -> some View {
ZStack(alignment: alignment) {
placeholder().opacity(shouldShow ? 1 : 0)
self
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ struct WishPlacesView: View {
)
}
)
.presentationDetents([.medium, .large])
}
.sheet(item: $reducer.selectedPlace) { place in
WishPlaceDetailSheet(place: place)
Expand Down
Loading