Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
abd3lraouf committed Mar 3, 2021
1 parent 7ba9c0d commit 4017fdb
Show file tree
Hide file tree
Showing 25 changed files with 443 additions and 261 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

<!--- Replace <OWNER> with your Github Username and <REPOSITORY> with the name of your repository. -->
<!--- You can find both of these in the url bar when you open your repository in github. -->
![Workflow result](https://github.com/AbdElraoufSabri/<REPOSITORY>/workflows/Check/badge.svg)
![Workflow result](https://github.com/AbdElraoufSabri/compose-challenge-1/workflows/Check/badge.svg)


## :scroll: Description
<!--- Describe your app in one or two sentences -->
A sample app for pet adoption


## :bulb: Motivation and Context
<!--- Optionally point readers to interesting parts of your submission. -->
<!--- What are you especially proud of? -->

- First time

## :camera_flash: Screenshots
<!-- You can add more screenshots here if you like -->
Expand Down
33 changes: 26 additions & 7 deletions app/src/main/java/com/example/androiddevchallenge/model/Pet.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
/*
* Copyright 2021 The Android Open Source Project
*
* Licensed 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
*
* https://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 com.example.androiddevchallenge.model

import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.runtime.Immutable
import androidx.compose.ui.tooling.preview.datasource.LoremIpsum
import com.example.androiddevchallenge.R

@Immutable
Expand Down Expand Up @@ -121,14 +135,19 @@ val addresses = listOf(

val descriptions = listOf(
"Not everything that is faced can be changed, but nothing can be changed until it is faced.",
"It doesn't matter how strong your opinion are. If you don't use your power for positive change, you are indeed part of the problem",
"It doesn't matter how strong your opinion are. If you don't use your power" +
" for positive change, you are indeed part of the problem",
"All great changes are preceded by choas",
"We all get scared and want to turn away, but it isn't always strength that makes you stay. Strength is also making the decision to change your destiny.",
"We must be impatient for change. Let us remember that our voice is a precious gift and we must use it",
"We all get scared and want to turn away, but it isn't always strength that" +
" makes you stay. Strength is also making the decision to change your destiny.",
"We must be impatient for change. Let us remember that our voice is a precious" +
" gift and we must use it",
"If you do not change direction, you might end up where you are heading",
"The moment of change is the only poem",
"The only way to make sense out of change is to plunge into it, move with it, and join the dance",
"Change will not come if we wait for some other person or some other time. We are the ones we’ve been waiting for. We are the change that we seek",
"The only way to make sense out of change is to plunge into it, move with" +
" it, and join the dance",
"Change will not come if we wait for some other person or some other time." +
" We are the ones we’ve been waiting for. We are the change that we seek",
)

val colors = listOf(
Expand Down Expand Up @@ -410,4 +429,4 @@ val allPets = listOf(
colors.random()
),

).shuffled()
).shuffled()
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.androiddevchallenge.ui

import android.os.Bundle
Expand All @@ -32,6 +31,4 @@ class MainActivity : ComponentActivity() {
PetsApp(onBackPressedDispatcher)
}
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.androiddevchallenge.ui

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.navigation.NavHostController
import androidx.navigation.NavType
import androidx.navigation.compose.*
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.navArgument
import androidx.navigation.compose.navigate
import androidx.navigation.compose.rememberNavController
import com.example.androiddevchallenge.ui.MainDestinations.PET_DETAIL_ID_KEY
import com.example.androiddevchallenge.ui.pet.PetDetails
import com.example.androiddevchallenge.ui.pets.Pets
Expand Down Expand Up @@ -61,7 +64,6 @@ fun NavGraph(startDestination: String = MainDestinations.PETS_ROUTE) {
}
}


/**
* Models the navigation actions in the app.
*/
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/com/example/androiddevchallenge/ui/PetsApp.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2021 The Android Open Source Project
*
* Licensed 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
*
* https://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 com.example.androiddevchallenge.ui

import androidx.activity.OnBackPressedDispatcher
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2021 The Android Open Source Project
*
* Licensed 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
*
* https://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 com.example.androiddevchallenge.ui.common

import androidx.compose.foundation.background
Expand All @@ -19,7 +34,6 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.androiddevchallenge.ui.theme.PetsTheme


@Composable
@Preview
fun LikeButton(modifier: Modifier = Modifier) {
Expand All @@ -38,4 +52,4 @@ fun LikeButton(modifier: Modifier = Modifier) {
contentDescription = if (checked.value) "Unlike" else "Like"
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2021 The Android Open Source Project
*
* Licensed 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
*
* https://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 com.example.androiddevchallenge.ui.common

import androidx.annotation.DrawableRes
Expand Down Expand Up @@ -46,7 +61,7 @@ fun OutlinedAvatar(
@Composable
fun LocalRoundAvatar(
@DrawableRes resource: Int,
backgroundColor:Color,
backgroundColor: Color,
modifier: Modifier = Modifier,
) {
Box(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2021 The Android Open Source Project
*
* Licensed 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
*
* https://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 com.example.androiddevchallenge.ui.common

import androidx.compose.runtime.Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,37 @@
/*
* Copyright 2021 The Android Open Source Project
*
* Licensed 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
*
* https://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 com.example.androiddevchallenge.ui.pet

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.material.Button
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Call
import androidx.compose.material.icons.outlined.LocationOn
Expand Down Expand Up @@ -76,7 +103,10 @@ fun PetDetails(pet: Pet, lovePet: (Long) -> Unit, adoptPet: (Long) -> Unit, upPr
}
}
ConstraintLayout {
val (name, addressIcon, address, like, age, color, weight, petStory, petStoryText, ownerAvatar, ownerPostedBy, ownerName, contactMe) = createRefs()
val (
name, addressIcon, address, like, age, color, weight, petStory, petStoryText,
ownerAvatar, ownerPostedBy, ownerName, contactMe
) = createRefs()
Text(
text = pet.name,
style = MaterialTheme.typography.h4,
Expand Down Expand Up @@ -115,25 +145,27 @@ fun PetDetails(pet: Pet, lovePet: (Long) -> Unit, adoptPet: (Long) -> Unit, upPr
top.linkTo(name.top)
bottom.linkTo(addressIcon.bottom)
end.linkTo(parent.end, margin = 16.dp)

}
)

PetDetailsCategoryCard("Age", "${pet.age} months",
PetDetailsCategoryCard(
"Age", "${pet.age} months",
modifier = Modifier
.constrainAs(age) {
top.linkTo(addressIcon.bottom, margin = 16.dp)
start.linkTo(addressIcon.start)
}
)
PetDetailsCategoryCard("Color", pet.color,
PetDetailsCategoryCard(
"Color", pet.color,
modifier = Modifier
.constrainAs(color) {
top.linkTo(addressIcon.bottom, margin = 16.dp)
start.linkTo(age.end, margin = 4.dp)
}
)
PetDetailsCategoryCard("Weight", "${pet.weight.toInt()} KG",
PetDetailsCategoryCard(
"Weight", "${pet.weight.toInt()} KG",
modifier = Modifier
.constrainAs(weight) {
top.linkTo(addressIcon.bottom, margin = 16.dp)
Expand Down Expand Up @@ -196,7 +228,8 @@ fun PetDetails(pet: Pet, lovePet: (Long) -> Unit, adoptPet: (Long) -> Unit, upPr
}
)

Button(onClick = { /*TODO*/ },
Button(
onClick = { /*TODO*/ },
shape = RoundedCornerShape(50),
modifier = Modifier
.constrainAs(contactMe) {
Expand All @@ -206,9 +239,8 @@ fun PetDetails(pet: Pet, lovePet: (Long) -> Unit, adoptPet: (Long) -> Unit, upPr
}
) {
Icon(Icons.Default.Call, contentDescription = "Contact ${pet.owner.name}")
Text(modifier = Modifier.padding(start = 10.dp),text = "Contact me")
Text(modifier = Modifier.padding(start = 10.dp), text = "Contact me")
}

}
}
}
Expand Down Expand Up @@ -245,6 +277,5 @@ fun PetDetailsCategoryCard(
modifier = Modifier.align(Alignment.CenterHorizontally)
)
}

}
}
Loading

0 comments on commit 4017fdb

Please sign in to comment.